J Harley
J Harley

Reputation: 285

Inserting a null value into the database

Good Morning,

Say I have an insert statement:

Insert INTO tblTest (fieldOne,FieldTwo,fieldThree) VALUES ('valueOne','valueTwo','null')

This statement doesn't seem to want to insert a null value into the database... I have also tried to insert the word "nothing".

Has anyone any ideas how to make this work? I am using SQL server 2005.

Upvotes: 0

Views: 1400

Answers (3)

Navaneethan
Navaneethan

Reputation: 2225

Insert INTO tblTest (fieldOne,FieldTwo) VALUES ('valueOne','valueTwo').

Upvotes: 0

hgulyan
hgulyan

Reputation: 8239

Try

Insert INTO tblTest (fieldOne,FieldTwo,fieldThree) VALUES ('valueOne','valueTwo',NULL)

Check for fieldThree not to be NOT NULL.

If you're trying to INSERT 'NULL' string, then just check if fieldThree is varchar type.

Upvotes: 1

Martin Milan
Martin Milan

Reputation: 6390

First of all, instead of 'null', try null (lose the quotes)

Then check that the fieldThree column on TblTest doesn't have any constraint prohibiting the use of null values...

Upvotes: 2

Related Questions