Reputation: 11817
I have a rather complex SELECT
statement in a stored procedure that I am updating to insert the rows from the select into a temp table. To define the temp table, I need to know the data type of each every item selected.
Is there a easy way (a script maybe) that I can use to determine the data types and the temp table structure instead of going to each table's definition in the select to find out what it is?
PS: I can't use a Common table expression as I need to use this temp table several times within the proc
Upvotes: 3
Views: 352
Reputation: 131
SELECT * INTO #temp FROM TABLE1
All columns in TABLE 1 gets into your temp table now
Upvotes: 0
Reputation: 86798
SELECT
blah
INTO
#temp
FROM
wibble
blah
and wibble
are not secret syntax. Please replace these with your own SQL :)
Upvotes: 5