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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CASE in SQL Server 7.0

Status
Not open for further replies.

BlackKnight

Programmer
Oct 18, 2000
348
US
Hi folks,

I have 3 fields: strCity, strState, strZip.
I want to concatenate them using a CASE in the folowing SQL 7 statement. I assumed TRUE is the return value from the isnull()function? I get an error of TRUE being an invalid column name. Thanx in advance.

========================
SELECT
...

[strCity] + (CASE ISNULL([strCity], '') WHEN TRUE THEN '' ELSE ', ' END) + [strState] + ' ' + [strZip] AS strFullCity etc....

================================

My outputted expression would be:

If strCity is null then CO 80525
else Longmont, CO 80525

Have a good one!
Keith
 
Hi,

Try this...

SELECT
...

CASE
WHEN [strCity] IS NULL THEN
[strState] + ' ' + [strZip]
ELSE
[strCity] + ', ' + [strState] + ' ' + [strZip] AS
END as strFullCity

etc...

Hope this works LOL

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top