May 21, 2010 at 4:26 pm
Hi,
I am getting "incorrect syntax near ','" error while inserting data into database. The reason, I am having this error is that I have Insert into statement as
INSERT INTO TableName VALUES ('column1', 'column 2', 'column 3', , 'Column 5', 'Column 6')
Now you see the comma after column 3 is giving an error. So, at Column 4 I am trying to insert null value for Integer data type.
So, definitely, I am doing something wrong here. My question is then, how to insert a null value in column with datatype integer.
Thanks,
May 21, 2010 at 5:48 pm
there are two ways;
you can not refer to the column at all, or you need to use the NULL keyword explicitly:
--define the columns being inserted, skip #4
INSERT INTO TableName (col1, col2, col3 , col5, col6)
VALUES ('column1', 'column 2', 'column 3', 'Column 5', 'Column 6')
--or
INSERT INTO TableName VALUES ('column1', 'column 2', 'column 3',NULL , 'Column 5', 'Column 6')
Lowell
May 22, 2010 at 12:11 am
Thank you
This answer my question.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply