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)
 Select from result of stored procedure

Author  Topic 

daman
Yak Posting Veteran

72 Posts

Posted - 2008-07-17 : 16:00:11
My current method of doing this task is
1) create temp table and populate it with a sproc
CREATE TABLE TEMP (MY_DATE DATETIME)
INSERT INTO TEMP
exec usp_get_available_dates @start_date,@end_date

2) Now select from that temp table
SELECT value from DATA_TABLE
WHERE date IN (select * from TEMP)


My question is if it's possible to skip the TEMP table and select directly instead. For example
SELECT value from DATA_TABLE
WHERE date IN (exec usp_get_available_dates @start_date,@end_date)

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-07-17 : 16:04:04
no, but you could make your get_available_dates a table valued function then JOIN to it.

Be One with the Optimizer
TG
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-18 : 04:56:07
or point 2
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 -