Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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,1Thanks.
rmiao
Master Smack Fu Yak Hacker
7266 Posts
Posted - 2008-07-11 : 23:53:42
Should create temp table first.
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 #tempFROM OPENROWSET('SQLOLEDB', '<server>';'<user id>';'<password>', ' exec dbo.MyStoredProc 89,1') AS tWHERE conditions if any
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.aspxMadhivananFailing to plan is Planning to fail