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 |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2006-11-03 : 10:06:11
|
| How can I conver zero length string(" ") to null? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-11-03 : 10:10:10
|
| Where is the zero length string?update tblset fld = nullwhere fld = ''==========================================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. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-11-03 : 10:12:02
|
select nullif(fld, '')Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-11-03 : 12:11:49
|
| " " is not a zero length string"" is a zero length stringJay White |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-03 : 13:02:59
|
Try SELECT LEN(' ') Peter LarssonHelsingborg, Sweden |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-11-03 : 13:26:18
|
Holy shit.declare @v varchar(10)select @v = ' 'select nullif(@v, '') Thanks for pointing that out ...Jay White |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-11-03 : 13:33:05
|
"Holy shit."It gets worse ....declare @v varchar(10)select @v = ' ' -- 10 spaces ...SELECT LEN(@v), DATALENGTH(@v)select nullif(@v, '') on this basis we decided that we would not hold "empty strings" and would stores NULLs instead ...Kristen |
 |
|
|
|
|
|