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)
 smalldatedatime

Author  Topic 

sardinka
Posting Yak Master

142 Posts

Posted - 2005-08-19 : 08:29:22
Can I do something like this:
set Birthdate=' '
If my Birthdate is smalldatetime with no default value

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-19 : 08:36:40
Yes
But the value will be stored as 1900-01-01 00:00:00


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sardinka
Posting Yak Master

142 Posts

Posted - 2005-08-19 : 08:46:49
So there is no way to get just empty datetime?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-19 : 08:47:41
NULL ?

Kristen
Go to Top of Page

sardinka
Posting Yak Master

142 Posts

Posted - 2005-08-19 : 08:52:33
I have Null but I need ''.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-19 : 08:54:19
>>I have Null but I need ''.

why?
Do you want to show them in Reports?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sardinka
Posting Yak Master

142 Posts

Posted - 2005-08-19 : 08:58:05
Some of my asp.net code doesn't have a logic to support return value Null from a db, so I was thinking to update NULL value to '' .
If it not possible I will add some logic to suppport NULL value in my code.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-19 : 09:06:36
Well
Use this

Select otherColumns, case when Birthdate is null then '' else Birthdate end from yourTable


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-08-19 : 09:25:09
I think the right thing to do is to have your code be able to deal with nulls, but otherwise Madhivanan's solution will work (with a tweek):

case when Birthdate is null then '' else convert(varchar,Birthdate,101) end

EDIT:
otherwise it will still come over as: 1900-01-01 00:00:00

Be One with the Optimizer
TG
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-19 : 09:40:15
Thats Correct TG

Did you notice that all numbers will work with empty string conversion?

select convert(varchar,'',0)
select convert(varchar,'',-10)
select convert(varchar,'',230948)


select convert(varchar,'',230948)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -