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 |
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2013-11-08 : 07:52:30
|
Hi, How do I show a text such as 'current' if there is nothing returned?The following sql is not quite right because it just returns a blank value and not the value of 'current' that I would likei.e.select field1 = case when field1='' then 'current'else field1end from tblMain where Field2=3 |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-11-08 : 08:17:24
|
quote: Originally posted by arkiboys Hi, How do I show a text such as 'current' if there is nothing returned?The following sql is not quite right because it just returns a blank value and not the value of 'current' that I would likei.e.select field1 = case when field1='' then 'current'else field1end from tblMain where Field2=3
That seems to be correct. The thing that may be tripping you up is that it might not be blank, it might be null. You can test that easily by making the following change to your queryselect field1 = case when COALESCE(field1,'')='' then 'current'else field1end from tblMain where Field2=3 |
|
|
|
|
|