Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

What's wrong with my query? :(

USE tempdb;
IF OBJECT_ID('dbo.OrderTotals', 'V') IS NOT NULL
DROP VIEW dbo.OrderTotals;
IF OBJECT_ID('dbo.OrderDetails', 'U') IS NOT NULL
DROP TABLE dbo.OrderDetails;
GO
CREATE TABLE dbo.OrderDetails
(
oid INT NOT NULL,
pid INT NOT NULL,
qty INT NOT NULL,
PRIMARY KEY(oid, pid)
);
INSERT INTO dbo.OrderDetails(oid, pid, qty) VALUES
(10248, 1, 10),
(10248, 2, 20),
(10248, 3, 30),
(10249, 1, 5),
(10249, 2, 10),
(10249, 3, 15),
(10250, 1, 20),
(10250, 2, 20),
(10250, 3, 20);
GO

If I execute that query, I get this error:

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ','.

share

migration rejected from stackoverflow.com Jul 3 '13 at 11:24

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by Martin Smith, Paul White, Marian, ypercube, gbn Jul 3 '13 at 11:24

If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Which line is highlighted when you double click on that error? –  quetzalcoatl Jul 3 '13 at 9:03
1  
Works fine on SQL Fiddle without the DROP TABLE bits at the top...(minus the GOs too). Have you tried running it without the drop table statements? –  Charleh Jul 3 '13 at 9:05
6  
Which version of SQL Server are you using? I think the "multi-row" insert was only introduced in 2008. –  a_horse_with_no_name Jul 3 '13 at 9:07
    
I think I just broke SQL Fiddle... :( - I tried this with SQL2008 and SQL2012 - didn't try 2005 - will try on my local 2005 server –  Charleh Jul 3 '13 at 9:07
2  
This question appears to be off-topic because it is not in the advanced querying category. –  Martin Smith Jul 3 '13 at 10:41