July 11, 2008 at 4:32 pm
In the following SQL, I had thought that my "IsNull" operator would detect when there is no record. It detects when p.TextBody is null, but the value of @PMH is nothing if there is no record.
How can I set @PMH to empty string when there is no record?
DECLARE @PMH as varchar(500)
SELECT @PMH=IsNull(p.TextBody,'')
FROM dbo.PartyText p
WHERE p.DataPointID=186
And p.PartyID=19396
print @PMH
Thanks for the help!!
Sam
July 11, 2008 at 9:24 pm
Like this:
DECLARE @PMH as varchar(500)
SELECT @PMH=''
SELECT @PMH=p.TextBody
FROM dbo.PartyText p
WHERE p.DataPointID=186
And p.PartyID=19396
print @PMH
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
July 12, 2008 at 8:26 am
THanks!
That seems so obvious now. Couldn't see it before.
Sam
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply