Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Inserting Null values in the database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-26 : 23:11:51
Amitabh writes "I have always wanted to know how, if possible, to insert a null value in the database. Let's say there is a form with optional fields such as an Address2 line. If a user enters nothing in the Address2 line, I would like SQL to insert nothing in the database. I would like to do that from the SQL statement so I don't have to check each field in the form with an if-then statement to see if it has been filled in.
For example,
Insert TableName (Address1, Address2, City, State, Zip) values
(variableAddress1, variableAddress2, variableCity, variableState, variableZip);

This same (modified)query should work whether variableAddress2 has any assigned value or is empty.
"
   

- Advertisement -