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 |
|
CreativeNRG
Starting Member
44 Posts |
Posted - 2006-04-09 : 14:53:42
|
| Is it possible in my select statement to replace the value of a field if it is an empty string ?If the column value returns an empty string I would like to replace it with a different string e.g. 'No Answer' ?Thankswww.creativenrg.co.uk |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-09 : 15:02:57
|
| select case when fld = '' then 'No Answer' else fld end ,...You might want to cater for null as well.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
CreativeNRG
Starting Member
44 Posts |
Posted - 2006-04-09 : 16:26:15
|
| Thanks for the help.Is it possible to cater for nulls in the same statement ?www.creativenrg.co.uk |
 |
|
|
pootle_flump
1064 Posts |
Posted - 2006-04-09 : 16:46:06
|
Yes - by including ISNULL() in the statement too |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-09 : 16:58:30
|
| select case when coalesce(fld, '') = '' then 'No Answer' else fld end==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-04-10 : 01:55:26
|
| "Oh, empty string ...."There is a toruous solution therefore:SELECT COALESCE(NullIf(Col, ''),'No Answer') AS NewCol FROM myTable99Kristen |
 |
|
|
|
|
|