dbTalk Databases Forums  

Execute a stored procedure and place results in a temporary table

microsoft.public.sqlserver.mseq microsoft.public.sqlserver.mseq


Discuss Execute a stored procedure and place results in a temporary table in the microsoft.public.sqlserver.mseq forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alastair Bell
 
Posts: n/a

Default Execute a stored procedure and place results in a temporary table - 02-24-2004 , 11:26 AM






Could someone please advise me on the syntax in Transact SQL to execute a stored procedure (that returns records) and then place the results in a temporary table

Thankyou - Alastair

Reply With Quote
  #2  
Old   
Vishal Parkar
 
Posts: n/a

Default Re: Execute a stored procedure and place results in a temporary table - 02-24-2004 , 12:02 PM






hi alastair,

--Two methods
1) you will have to create a table first and then insert output of stored procedure using
following syntax.

insert into <table> exec <stored_procedure>

create table #t(
spid int null,
ecid int null,
status varchar(500) null,
loginname varchar(500) null,
hostname varchar(500) null,
blk int null,
dbname sysname null,
cmd varchar(800) null)

insert into #t exec sp_who

2) without precreating the table you will have something as follows

EXEC sp_serveroption <server name>, 'data access' , 'true'

select *
into #temptable
from openquery (<server name>, 'exec sp_who')



--
Vishal Parkar
vgparkar (AT) yahoo (DOT) co.in




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.