Posts

Showing posts with the label sql-server-2014

Error message on INTO keyword

Error message on INTO keyword Does anyone know why the INTO keyword works in the first method below, but not the second? I got both methods from the first 5 mins of this video about creating temporary tables: https://www.youtube.com/watch?v=3ZtYrELHP8M Method 1 SELECT CAST (date AS DATE) AS #DateWk INTO #DateWk FROM AggregatedSalesHistory WHERE date >= '1-2-2014' SELECT * FROM #DateWk When I try method 2, I get the error message below: Incorrect syntax near the keyword 'INTO'. This is the code for method 2: CREATE TABLE #DateWeek ( Title VARCHAR(MAX), ReleaseDate DATETIME ) INSERT INTO #DateWk SELECT CAST (date AS DATE) AS #DateWk, INTO #DateWk FROM AggregatedSalesHistory WHERE date >= '1-2-2014' SELECT * FROM #DateWk 2 Answers 2 This is not a valid syntax if you are going to compare with method1 : INSERT INTO #Date...