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
 .NET Inside SQL Server (2005)
 Temporary Table

Author  Topic 

Kotti
Posting Yak Master

129 Posts

Posted - 2009-01-07 : 05:33:18
Hi friends

I am new to stored procedure

when i execute the below query i will get some result .what i need is ,i need to store the result in temporary table

EXEC dbo.FindNearestStores '07608'

May i know how to do this?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-07 : 05:42:44
create table #temp (col1 varchar(...), ...) -- whatever resultset your stored procedure returns

insert #temp
exec dbo.FindNearestStores '07608'


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Kotti
Posting Yak Master

129 Posts

Posted - 2009-01-07 : 06:11:58
the table should be created at runtime only and not in the database itself
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-07 : 06:23:57
What is the consumer of the data provided by your stored procedure?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Kotti
Posting Yak Master

129 Posts

Posted - 2009-01-07 : 06:39:09
I cant able to understand your question.What i need is ,i need to save the the result in a temporary table.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-07 : 06:49:28
create table #temp (col1 varchar(...), ...) -- whatever resultset your stored procedure returns

insert #temp
exec dbo.FindNearestStores '07608'



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Kotti
Posting Yak Master

129 Posts

Posted - 2009-01-07 : 07:29:47
insert #temp
exec dbo.FindNearestStores '07608'

When i use the above ,the result is inserting in the temporary table.
when i use the query by changing the values as below

insert #temp
exec dbo.FindNearestStores '09652'

result is inserted into the temporary table,here the result should not be inserted ,it should be overwrited


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-07 : 08:02:01
insert #temp
exec dbo.FindNearestStores '07608'

truncate table #temp

insert #temp
exec dbo.FindNearestStores '09652'


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -