May
9
Written by:
Steve Gray
5/9/2011 4:55 PM
Here’s a quick example of how to insert the results of a stored procedure into a table. It’s pretty simple, not much explanation needed
- Create Proc usp_getItems
- as
-
- --dummy return values
- select 'ITM001' as itemnmber, 'Big Item' as itemDescription
- union
- select 'ITM002' as itemnmber, 'Little Item' as itemDescription
- union
- select 'ITM003' as itemnmber, 'Red Item' as itemDescription
- union
- select 'ITM004' as itemnmber, 'Blue Item' as itemDescription
-
- go
-
- --send the results of the stored proc into a table
-
- Declare @myTemp as table (itemnmbr varchar(10), itemdescription varchar(30) )
-
- insert into @myTemp (itemnmbr, itemdescription)
- exec usp_getItems
-
- select * from @myTemp
The results look like this:

As always, I welcome your comments!