find empty sring in sql server
find empty sring in sql server
am 13.06.2006 20:59:02 von sdmusicmaker
ok i kinda feel dumb here but i have a CHAR column in SQL server who's values
could be alpha, Null (by default),or blank.
I cant seem to test for the blank. i tried ' ' and " " but itd oes not
work. In Query analizer this works:
select wo_user_alpha_1 from EMORDLIN_SQL where wo_user_alpha_1 =' '
But in ASP this does not work:
if Recordset1("wo_user_alpha_1") = "''" then
response.write("String Thing")
end if
when i test like this:
if Recordset1("wo_user_alpha_1") = " " then
response.write("String Thing")
end if
it does not work either...what i'm i missing?
sd
Re: find empty sring in sql server
am 13.06.2006 21:18:36 von unknown
If it's a char, wouldn't the value be ' ' where the spaces are the length
of the char field definition?
Ray at work
"sdmusicmaker" wrote in message
news:AA1F2AC0-EE8A-4A24-A635-F8C430404F74@microsoft.com...
> ok i kinda feel dumb here but i have a CHAR column in SQL server who's
> values
> could be alpha, Null (by default),or blank.
>
> I cant seem to test for the blank. i tried ' ' and " " but itd oes not
> work. In Query analizer this works:
> select wo_user_alpha_1 from EMORDLIN_SQL where wo_user_alpha_1 =' '
>
> But in ASP this does not work:
>
> if Recordset1("wo_user_alpha_1") = "''" then
> response.write("String Thing")
> end if
>
> when i test like this:
> if Recordset1("wo_user_alpha_1") = " " then
> response.write("String Thing")
> end if
>
> it does not work either...what i'm i missing?
>
> sd
Re: find empty sring in sql server
am 13.06.2006 21:30:02 von sdmusicmaker
dunno, in QA there is no space between the single quotes and it pulls back
the records ok so it does not need ' ' to work.
sd
"Ray Costanzo [MVP]" wrote:
> If it's a char, wouldn't the value be ' ' where the spaces are the length
> of the char field definition?
>
> Ray at work
>
> "sdmusicmaker" wrote in message
> news:AA1F2AC0-EE8A-4A24-A635-F8C430404F74@microsoft.com...
> > ok i kinda feel dumb here but i have a CHAR column in SQL server who's
> > values
> > could be alpha, Null (by default),or blank.
> >
> > I cant seem to test for the blank. i tried ' ' and " " but itd oes not
> > work. In Query analizer this works:
> > select wo_user_alpha_1 from EMORDLIN_SQL where wo_user_alpha_1 =' '
> >
> > But in ASP this does not work:
> >
> > if Recordset1("wo_user_alpha_1") = "''" then
> > response.write("String Thing")
> > end if
> >
> > when i test like this:
> > if Recordset1("wo_user_alpha_1") = " " then
> > response.write("String Thing")
> > end if
> >
> > it does not work either...what i'm i missing?
> >
> > sd
>
>
>
Re: find empty sring in sql server
am 13.06.2006 21:42:56 von reb01501
sdmusicmaker wrote:
> ok i kinda feel dumb here but i have a CHAR column in SQL server
> who's values could be alpha, Null (by default),or blank.
>
> I cant seem to test for the blank. i tried ' ' and " " but itd oes
> not work. In Query analizer this works:
> select wo_user_alpha_1 from EMORDLIN_SQL where wo_user_alpha_1 =' '
>
> But in ASP this does not work:
>
> if Recordset1("wo_user_alpha_1") = "''" then
You're asking if it contains two apostrophes ... that won't work
> response.write("String Thing")
> end if
>
> when i test like this:
> if Recordset1("wo_user_alpha_1") = " " then
Now you're asking if it contains a space character. Again, that won't
work
> response.write("String Thing")
> end if
>
> it does not work either...what i'm i missing?
You're missing the test for the empty string:
if Recordset1("wo_user_alpha_1") = "" then
Actually, this may lead to an "invalid use of null" error if the field
contains a null, so this will work better:
if Recordset1("wo_user_alpha_1") & "" = "" then
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.