Skip to content
Advertisement

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement