简体   繁体   中英

Can't insert multiple rows in SQL Server Manager Express 2005

I have a Table HORAS_X with ID_HORA(int), ID_ZONA(int), DESCRIPCION(nvarchar), COMIDA(bit), META(int), NUMERO(int) .

I can insert a single row like:

INSERT INTO HORA_X 
   (ID_HORA,ID_ZONA,DESCRIPCION,COMIDA,META,NUMERO) 
VALUES
   (2,2,'06:00-07:00',0,174,1);

And it works.

However when I try to insert multiple rows like this:

INSERT INTO HORA_X 
   (ID_HORA,ID_ZONA,DESCRIPCION,COMIDA,META,NUMERO) 
VALUES 
   (3,3,'06:00-07:00',0,174,1),
   (4,4,'06:00-07:00',0,174,1);

It throws the error

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

Is my Syntax wrong? I checked online and it's supposed to be fine. And yes, I have restarted SQL Server Manager, thanks for any lead and help.

If I remember correctly, SQL Server 2005 does not support VALUES table value constructor. It was introduced in SQL Server 2008, so for SQL Server 2005 you need to use the following statement:

INSERT INTO HORA_X (ID_HORA,ID_ZONA,DESCRIPCION,COMIDA,META,NUMERO) VALUES (3,3,'06:00-07:00',0,174,1)
INSERT INTO HORA_X (ID_HORA,ID_ZONA,DESCRIPCION,COMIDA,META,NUMERO) VALUES (4,4,'06:00-07:00',0,174,1);

Notes: SQL Server Manager Express 2005 is a tool, but I assume, that you are using SQL Server 2005.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM