Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datetime datatype null value?

Status
Not open for further replies.

bellsports

Programmer
Joined
Oct 22, 2001
Messages
2
Location
ZA
I want to load blank/null dates into a Microsoft SQL 2000 database. What does SQL recognize as a null value for datetime?

Thanks!
 
NULL

as in INSERT table (field_dt) VALUES (NULL)
 
I have tried using "null" as the value for my import file (I am updating the database using DTS) and the DTS does not like the "null". I have an import txt file, delimited by ";" with dates in it. Some dates do not have a value. I am having a problem loading this file due to the null values of some of the dates. On the export, I can convert a null value to an acceptable value for SQL but I am having trouble figuring out what it will take.

Any suggestions?

Thanks
 
How about an empty field? e.g.

Apples;10/22/2001;...
Pears;;...

It's important that field is empty (no spaces) and that the column in your table allows nulls.
 

You'll have to modify the DTS transformation script. I use VB scripting so this sample will be a VB script sample.

Test the source column for each date in the file. If the date is empty or invalid store NULL in the destination column.

IF trim(DTSSource("Col006"))="" THEN
DTSDestination("dt_payment_pay") = NULL
ELSE
DTSDestination("dt_payment_pay") = DTSSource("Col006")
END IF Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top