var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: select from a stored procedure?
Hey all! I have a quick question. Is it possible do formulate a select query where one of the tables is a recordset returned from a stored procedure? If so, what's the syntax?
In other words, if I have a stored proc whose last command is:
sum([Total]) as [Total]
from #tmp t
group by [Region_Code],
order by [Region_Code],
Then can I somehow get a handle on that cursor and join it to another table etc? Thanks!
Aha! Apparently I can do this with openrowset but I am using windows authentication and anyways dont want to hardcore logins and passwords for my DB. I've never used openrowset, can I use it specifying the current database and forego having to enter security credentials?
No..but you could put the results of an execution in to a table then join to that
INSERT INTO myTable99(col list) EXEC sproc
...or rewrite your stored procedure as a User-defined table function. Then it is easy use it in a select statement.
Yah I thought of that except that the existing proc uses a TON of temp tables which apparently you cannot use in a function
OK, so do what I suggested.....