Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Store stored proc values to table

Author  Topic 

ss.mmm
Starting Member

1 Post

Posted - 2008-07-11 : 14:21:23
insert into #temp exec dbo.MyStoredProc 89,1
(MyStoredProc requires 2 integer parameters.)

The above works fine but in my stored proc where I write this insert statement, I need to create the #temp table and MyStoredProc results in 100 columns.
I just need 5 columns to be stored in #temp.

I need something like below. (As you would know, am making it clear, below does not work!!)
select col1,col2,col3,col4 into #temp
exec dbo.MyStoredProc 89,1

Thanks.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-07-11 : 23:53:42
Should create temp table first.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-12 : 00:29:08
try with OPENROWSET like this:-

SELECT t.col1,t.col2,t.col3,t.col4 into #temp
FROM OPENROWSET('SQLOLEDB', '<server>';'<user id>';'<password>',
' exec dbo.MyStoredProc 89,1') AS t
WHERE conditions if any
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-12 : 05:15:00
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -