Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXEC sp_executesql @mysql INTO ....

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
US
I need to create a dynamic sql select statement and put the results into a table variable.

I have one stored procedure which creates the dynamic sql and executes it using:
Code:
EXEC sp_executesql @mysql

In another stored procedure, I would like to get the result set from that SPROC into a table variable so that I can join it in another query.

Obviously, this won't work
Code:
DECLARE @results table(Field1 int, [etc...])
INSERT INTO @results EXEC dbo.Sproc_that_returns_results

I am not up to speed on UDFs, yet from what I understand I will need to create a UDF for the first SPROC that returns a table variable. Can someone please tell how this is done?

Thanks!
[pipe]
 
Doh! Sorry, didn't see this thread:
thread183-644073

[pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top