Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Down in column concat

Author  Topic 

iswan
Starting Member

28 Posts

Posted - 2007-07-19 : 07:16:27
Hai I have one dowt in the column concatination

Input Table:Test

RowID EFirstName ELastName ENo
1 Rez Ali 1
2 RAABU NULL 2
3 Sam NULL 3

Needed Output Str:
1~Rez~Ali~1
2~Raabu~~2
3~Sam~~3

Query:
declare @Tex varchar(1024)
select @Tex=* from Test where RowId=@i
PRINT @Tex


I am trying like this but don't know How to get this output

Iswan


iswan
Starting Member

28 Posts

Posted - 2007-07-19 : 07:45:18
Ya, I Found it the query

select a1+'~'+case when a2 is null then '' when a2 is not null then a2 end
from Test where RowID=@i

Thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-19 : 07:54:15
You can use isnull() or coalesce() function
SELECT a1 + '~' + ISNULL(a2, '')
FROM Test
WHERE RowID = @i



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -