I want to do
SELECT @var1, @var2
INTO #myTempTable
I keep getting error
There is already an object named '#myTempTable' in the database.
My code goes
CREATE TABLE #myTempTable
(
[value1] varchar(10),
[value2] varchar(20)
)
declare @var1 varchar(10), @var2 varchar(20)
SELECT @var1 = [value1], @var2 = [value2]
FROM somePermTable
where Condition = true
SELECT @var1, @var2 INTO #myTempTable
drop table #myTempTable
What am I doing wrong?
Copyright Notice:Content Author:「P.Brian.Mackey」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7351742/sql-how-to-select-declared-variables-into-temp-table