I want to create a table variable or temporary table, using data from another table but with an extra column.
I know I could use SELECT INTO as follows
SELECT *
INTO #TempTable
FROM Existing_Table
WHERE Section = 2
and then use
ALTER TABLE #TempTable ADD New_Column
And finally
DROP #TempTable
I will then be looping through each row with a dynamically called stored procedure to place values in the new column. Its not a big table.
Is that the best way? My understanding is that I cannot use the above with a table variable.
Thanks
Chris.