all groups > sql server mseq > september 2003 >
You're in the

sql server mseq

group:

2 simple Q's


2 simple Q's Mary
9/29/2003 8:10:55 AM
sql server mseq:
I have two simple questions - well simple for the experts
anyway - but I am struggling with them.

1. I need to do the following: I have two fields:
claddr1 and claddr2. If claddr2 is not null, I need to
include it with claddr1 with a <CR><LF> in between.
Seems simple enough but I have tried many things and
nothing has worked. The latest thing I have tried is:

select claddr1 + IIf(ISNULL(claddr2), '', ''<CR><LR>' +
claddr2) from client

I was using a case statement, which also didn't work but
someone told me to try IIf. Any ideas?

2. The other thing I need to do is break city, state and
zip from one field into three fields.

Thanks in advance.

Re: 2 simple Q's Vishal Parkar
9/29/2003 8:27:03 AM
Use CASE expression
See following example

select claddr1 +
case when claddr2 is not null then char(13) + char(10) +
claddr2 else '' end as 'Concatenation'
--Use above CASE expression
--Change ELSE part according your requirement.
from
(select 'vishal' claddr1, null claddr2
union all
select 'vishal' , 'parkar') a

- Vishal

[quoted text, click to view]
AddThis Social Bookmark Button