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
 Mutluple values insert error [Compact 3.5 SP1]

Author  Topic 

Largo
Starting Member

22 Posts

Posted - 2009-09-21 : 06:47:10

I am trying to insert multiple values with single INSERT statement, but it fails. What's wrong?




CREATE TABLE Division
(
DivisionID int PRIMARY KEY
);

INSERT INTO Division(DivisionID) VALUES (1),(2);



Here's error:
There was an error parsing the query. [ Token line number = 1,Token line offset = 44,Token in error = , ]


-----
There is no knowledge that is not power.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-09-21 : 07:33:08
If you were using SQL 2008, you could do this.

If you are using any other version, you need to do:

insert into <table>
select 1
union select 2
..etc
Go to Top of Page

Largo
Starting Member

22 Posts

Posted - 2009-09-21 : 08:33:30
I see. :( SQL Server 2008 allows such syntax. :)

-----
There is no knowledge that is not power.
Go to Top of Page
   

- Advertisement -