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.
| Author |
Topic |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2006-11-02 : 16:24:29
|
| I code a insert function. If a text box is "" value, data in SQL server become "1/1/1900".How to void it and make it always display <Null> if "" insert it? |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2006-11-02 : 16:31:51
|
| create table #tmp ( c1 datetime )declare @tst as varcharset @tst = ''insert into #tmp values (@tst)insert into #tmp values (case(@tst) when '' then NULL else @tst END)select * from #tmpdrop table #tmp"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-02 : 17:29:51
|
[code]insert into #tmp values (nullif(@tst, ''))[/code] KH |
 |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2006-11-02 : 17:45:57
|
| I love it when I learn something new. Thanks"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-11-02 : 20:12:48
|
| >>If a text box is "" value, data in SQL server become "1/1/1900".Before sending that to table you should for '' and send as NULLIf trim(textbox)='' theninsert into #tmp values (NULL)elseinsert into #tmp values (yourDate)End ifMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|