Home » Microsoft SQL Server Error: SQL SERVER – Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ‘)’ or msg 102 level 15 state 1 line 3 incorrect syntax near ‘ ‘

Microsoft SQL Server Error: SQL SERVER – Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ‘)’ or msg 102 level 15 state 1 line 3 incorrect syntax near ‘ ‘

sql server DBA 999

Microsoft SQL Server Error: SQL SERVER – Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ‘)’ or msg 102 level 15 state 1 line 3 incorrect syntax near ‘ ‘

Details of Error:

This error message occurs if we use GETDATE() like function as a parameter to Stored Procedure or Function Statement. or the second error is pertaining to problem when inserting data can be solved by making the column not null and also can be made default to some value.

Actual error message:

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ‘)’.’

Resolution:

This problem can be solved by using a local variable for storing the value of Getdate() instead of passing GETDATE() function as parameter directly in the execute statement and then pass the assigned local variable as parameter.

or Another error message similar is below

Another error message is:

msg 102 level 15 state 1 line 3 incorrect syntax near ' '

Resolution:

This problem when inserting data can be solved by making the column not null and also can be made default to some value.

alter table tablename
add default 0 for person_id

or

alter table TableName
Alter Column ColumnName NOT NULL SET DEFAULT 0

Additional information below:

Please note that alter column may need column to be dropped and re-created which can not useful when table is very large in size

Leave a Reply

Your email address will not be published. Required fields are marked *