Example of importing the stored procedure

zhaozj2021-02-16  54

1. Create a table and import data:

Create Table A (ID INT, Data Varchar (10))

INSERT INTO A (ID, DATA) SELECT 1, 'DS'Union All Select 2,' DSF'Union All Select 3, 'Sdf'Union All Select 4,' AdS'Union All Select 5, 'SDA'go

2. Create a stored procedure, return a result set

Create Procedure SP_TestasBegin Select ID, Data from A ORDER BY ID DESC END

3. Import the results of the stored procedure into a temporary table

Create Table #tmp (ID Int, Data Varchar (10)) Insert Into #tmp (ID, DATA) EXEC SP_TESTSELECT * from #tmpdrop table #TMP

4, display result

(The number of rows affects is 5 lines)

ID DATA ------------ ---------- 5 SDA4 ADS3 SDF2 DSF1 DS

(The number of rows affects is 5 lines)

转载请注明原文地址:https://www.9cbs.com/read-18854.html

New Post(0)