Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
select distinct case when item is null then replace(item,null,'-') else itemend end as item from itemstablei want to replace all null values to '-'...but still i m getting null values..syntax is correct still not getting results..can anyone help?thanks.
jdaman
Constraint Violating Yak Guru
354 Posts
Posted - 2008-03-04 : 12:51:31
select distinctcase when item is null then '-'else itemendend as itemfrom itemstable
blindman
Master Smack Fu Yak Hacker
2365 Posts
Posted - 2008-03-04 : 13:10:11
This should get you what you want:
select coalesce(item, '-') as Itemfrom itemstable
...but if you still see "nulls", they are probably zero-length strings and this will convert them:
select coalesce(nullif(item, ''), '-') as Itemfrom itemstable
e4 d5 xd5 Nf6
sqlhelp14
Yak Posting Veteran
55 Posts
Posted - 2008-03-04 : 13:16:06
thanks jdamanand blindmangot the correct results..