October 31, 2011 at 12:27 pm
Is there a way to make the following thing happen in SQL:
@STR = 'USP parm1, parm2'
select *
into BLAH
Exec (@Str)
I know you can do:
insert into BLAH
Exec (@Str)
but I am trying to create the table BLAH from the output instead of needing to have the table defined before hand.
Thanks.
<><
Livin' down on the cube farm. Left, left, then a right.
October 31, 2011 at 2:01 pm
You could do it with openrowset but it would be rather ugly. It is usually easier to just create the table first. Here is a link from a discussion today doing the very same thing.
http://www.sqlservercentral.com/Forums/Topic1198143-338-1.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 31, 2011 at 2:32 pm
I agree with Sean, it is so much cleaner to define the table first.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
November 1, 2011 at 8:40 am
Thanks.
<><
Livin' down on the cube farm. Left, left, then a right.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply