I am using Microsoft SQL Server Management Studio, I am trying to run the following query to input values into a temporary table to use later:
CREATE TABLE #temptable
(colnumber varchar(15), dispcode varchar(10))
INSERT INTO #temptable (colnumber, dispcode)
VALUES
('col5', '811'),
('col6', '817'),
('col7', '823'),
('col8', '825');
When running I get the following error:
Msg 102, Level 15, State 1, Line 50
Incorrect syntax near ','.
Which points to the line "('col5', '811'),"
Could anyone help me identify the problem here?
For SQL Server version <2008 use this:
INSERT INTO #temptable (colnumber, dispcode)
SELECT 'col5', '811'
UNION ALL SELECT 'col6', '817'
UNION ALL SELECT 'col7', '823'
UNION ALL SELECT 'col8', '825'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With