INSERT INTO [Temp].[dbo].[Student]
([Fname], [Lname], [Gender])
VALUES
(N'Aname', N'Alname', N'Male')
GO
This codes workes fine but when I try to add multiple values it gives me an error
Error: Incorrect syntax near ','.
USE TEMP
GO
INSERT INTO [Temp].[dbo].[Student]
([Fname], [Lname], [Gender])
VALUES
(N'Aname', N'Alname', N'Male'),
(N'Bname', N'Blname', N'Male')
GO
This indicates there is an incorrect symbol in the criteria of the query.
Syntax errors are mistakes in the source code, such as spelling and punctuation errors, incorrect labels, and so on, which cause an error message to be generated by the compiler.
User is a reserved keyword, so you must use square brackets to make it explicit that you mean the object named "User" it, i.e. use [User] instead of User .
In order to use the multi-row VALUES(),()
syntax, you need to be running SQL Server 2008 (or newer).
Since you are running SQL Server 2005, you need to run separate insert statements, use UNION/UNION ALL, or upgrade the instance (which is separate from Management Studio, which is just a client tool you use to connect to instances running any number of versions of SQL Server).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With