dragonwell
Programmer
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:
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
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] [pipe] [pipe]](/data/assets/smilies/pipe.gif)
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] [pipe] [pipe]](/data/assets/smilies/pipe.gif)