insert data from stored procedure into table 1

insert data from stored procedure into table

CREATE TABLE #TestTable ([name] NVARCHAR(256), [database_ID] INT);

INSERT INTO #TestTable
EXEC GetDBNames

-- Select Table
SELECT *
FROM #TestTable;

Here is what the above code is Doing:
1. Create a temporary table called #TestTable
2. Insert the results of the GetDBNames stored procedure into the #TestTable
3. Select the results from the #TestTable

The results of the above code will look like this:

name database_ID
master 1
tempdb 2
model 3
msdb 4

Similar Posts