Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help please INSERT multiple rows

Author  Topic 

Buzzard724
Yak Posting Veteran

66 Posts

Posted - 2009-08-13 : 10:01:57
I have the following error message

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

when I run this code - not at all sure why the syntax is incorrect

Create TABLE TestPostMap
(Post VARCHAR (300), SIRCode VARCHAR (5));


Insert into TestPostMap(Post, SIRCode)
Values ('Artistic Director', '01'),
('Assistant Management Accountant', '12'),
('Assistant Management Accountant', '12')

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-08-13 : 10:05:33
Insert into TestPostMap(Post, SIRCode)
Values ('Artistic Director', '01')

Insert into TestPostMap(Post, SIRCode)
('Assistant Management Accountant', '12')

Insert into TestPostMap(Post, SIRCode)
('Assistant Management Accountant', '12')

Or use SELECT ... UNION instead of VALUES
Go to Top of Page

rocknpop
Posting Yak Master

201 Posts

Posted - 2009-08-13 : 10:22:47
Hi Buzzard724, it seems you are using sql 2008 syntax in sql 2000/2005. For sql 08 it seems fine. For 2000/2005 you could follow Yellowbug's reply.

--------------------
Rock n Roll with SQL
Go to Top of Page

Buzzard724
Yak Posting Veteran

66 Posts

Posted - 2009-08-13 : 11:22:10
ah! now I understand - will do the repeating statement route in 2005 - thank you both for your help and the distinction about 2008 syntax
Go to Top of Page
   

- Advertisement -