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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing <NULL> to smalldatetime field

Status
Not open for further replies.

woyler

Programmer
Jun 20, 2001
678
US
Hi,
I am having a bit of a problem with SQL syntax for SQL Server.
I have a field(MY_DATE), of a smalldatetime data type.
When I pass a NULL value to it either from VB or in Query Analyzer, it is assigned '1/1/1900'.
I have tried values of
'<NULL>'
&quot;&quot;
''
CONVERT(DATETIME,'',102)

Am I missing something?
Tahnks in advance,
Bill
 
Hi I am running slq97 and tried thsi

create table temp1
(my_date smalldatetime null)

insert into temp1
values(null)

select * from temp1

It seems to work, maybe I am misunderstanding something. Let me know.

Chuck
 
The work around I found was:

INSERT INTO TABLE
(STRING_FIELD,DATE_FIELD)
VALUES('1212',1,CONVERT(DATETIME,NULL))

Thanks for your responses
 
Thanks woyler, we ran into this problem before and used a If.. then evaluation to get around it but your solution is better than that, Thanks

km
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top