Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinguishing between a string full of spaces and an empty string 2

Status
Not open for further replies.

RebLazer

Programmer
Jun 7, 2002
438
0
0
US
How is it possible in SQL Server 2000 to distinguish between an empty string and one full of spaces (i.e. " ")? For example, when I do

[tt]
set @qstr = case
when @first_nm = '-1 [NULL]' then @qstr + 'cnt_first_nm = NULL, '
when @first_nm <> '' then @qstr + 'cnt_first_nm = ''' + @first_nm + ''', '
else @qstr
end[/tt]

and @first_nm = &quot; &quot;, it executes the &quot;else&quot;, not the second &quot;when&quot; like I want it to!

Thanks so much,
Lazer [rainbow]
 
did you consider using DATALENGTH ( expression ) and isnull() ?
 
Mak,

Thanks for your very quick reply!

Perhaps I do not understand what you mean. I don't know how many spaces there are so that I could predict the DATALENGTH.

Could you explain that a bit?

Thanks very much,
Lazer
 
It seemd you are trying to execute @qstr?
Maybe you need to be more specific,
(1)what is @qstr
(2)Do you need to ge tthe string length or someother?
(3)can you show the execute sentence?why you said @first_nm only execute the else?

Provide the essential info is very important.Instead of staying in question loop.
(But not post the whole query)
 
Thanks, Terry (and Claire, too!)!

Lazer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top