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
 General SQL Server Forums
 New to SQL Server Programming
 Incorrect syntax in insert many rows

Author  Topic 

jpol
Starting Member

1 Post

Posted - 2015-02-18 : 03:59:23
Hi
I create table with automatically generate the next ID.

create table #people
(id integer identity primary key not null,
name varchar(20),
surname varchar(30),
number Char(11)
);


and next I would like to add many lines
insert into #people (name, surname, number)
VALUES
('Anne', 'Ferguson', '123456789'),
('Eve', 'Atkinson', '234567891'),
('John', 'Smith','345678912');


and I've got:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ','.

This is something wrong with the row ('Anne...

I use sql MS server 2008
Thank u for help.

pradeepbliss
Starting Member

28 Posts

Posted - 2015-02-18 : 05:29:50
Insert into #People(name, surname, number)
select 'Anne', 'Ferguson', '123456789'
union all
select 'Eve', 'Atkinson', '234567891'
union all
select 'John', 'Smith','345678912'
Go to Top of Page
   

- Advertisement -