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 |
nrsh_ram
Starting Member
3 Posts |
Posted - 2010-06-15 : 05:40:05
|
hi to all...i need help..i have a set of data where its retrieve a data & null...the column is datetimefor null value i want to replace it with '-' chari try like thisSELECT REPLACE(NULL,NULL,'-') output..still appear NULL...coz inside there its nothing to have to replace...what should i do for output '-'? |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-15 : 05:46:41
|
select isnull(Columnname,'-') No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-15 : 05:49:39
|
you should be using ISNULL() to do that. REPLACE does not work for NULL value.Anyway, what you wanted is just a presentation issue. You should be handling that in your front end application where the data is being displayed.If you really want to do it in the T-SQL side, then you should also convert the datetime to a string select isnull(convert(varchar(10), datecol, 121), '-')from yourtable KH[spoiler]Time is always against us[/spoiler] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-15 : 06:20:46
|
You can't have both valid dates as well as - for NULL valuesMadhivananFailing to plan is Planning to fail |
|
|
nrsh_ram
Starting Member
3 Posts |
Posted - 2010-06-15 : 20:20:27
|
quote: Originally posted by madhivanan You can't have both valid dates as well as - for NULL valuesMadhivananFailing to plan is Planning to fail
ok Madhivanan,can u advice me the correct way to get the exact output...i want change the null to string...the changes that not for overall column bcoz it will change the format of datetime to string..plz help me.. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-15 : 20:35:26
|
quote: Originally posted by nrsh_ram
quote: Originally posted by madhivanan You can't have both valid dates as well as - for NULL valuesMadhivananFailing to plan is Planning to fail
ok Madhivanan,can u advice me the correct way to get the exact output...i want change the null to string...the changes that not for overall column bcoz it will change the format of datetime to string..plz help me..
Do it in your front end application KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|
|
|