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 |
emyk
Yak Posting Veteran
57 Posts |
Posted - 2013-07-25 : 15:36:05
|
I am trying to check for a null or empty value for a column (nvarchar 7,null). if null or empty to return a value (1).So far I tried isnull and Len without any luck.select isnull(col1,'1') from table1 -- Returns 0 rows.select CASE WHEN Len(col1) < 0 THEN '1' -- Returns 0 rowsSQL SERVER 2008.thanks |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-25 : 15:43:59
|
[code]SELECT * FROM YourTable WHERE col1 IS NULL OR col1 = '';[/code]This will return even if col1 has just a space (or just multiple spaces). |
|
|
ugh3012
Yak Posting Veteran
62 Posts |
Posted - 2013-07-25 : 15:54:37
|
select isnull(col1,'1') from table1 is right, but use number only. Do not use '' unless it is a string field. select isnull(col1,1) from table1 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|