I am using SQL Server 2012 and I want to perform the following operations using T-SQL:
Create a temporary table (let's call it
#temptable).Insert values from tables located in an existing database into
#temptableusing aSELECTstatement.Write a
SELECTstatement that will query the#temptable.
I have tried the following but it seems the syntax is not correct or perhaps what I am trying to do is not allowed.
USE MyDatabase
CREATE TABLE #temptable
GO
INSERT INTO #TempTable
SELECT [Col A], [Col B], [Col C]
FROM MYLIST
WHERE [MONTH OF STAY] = '2018-03-01'
AND [Property] = 'ABC'
SELECT * FROM #temptable
How do I move forward with this?