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
 Transact-SQL (2000)
 Concatination..

Author  Topic 

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-11-08 : 01:46:30
Hi All,

I have data in this format

Loc1 Value
1 WC001
1 WC0002
1 WC0003
2 WC0002
2 WC0008
2 WC0007


Now i want the query for the data to be in this format

Loc1 Value
1 WC001@WC0002@WC0003
2 WC0002@WC0008@WC0007


Any Sugesstions.. ???

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-08 : 01:49:49
Refer this
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-11-08 : 02:18:25
quote:
Originally posted by madhivanan

Refer this
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail



Thanks Madhiivanan..

But I got it work through this function..

quote:



CREATE FUNCTION dbo.ConcatLoclib4(@Loclib4 varchar(9), @ConString varchar)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @Output VARCHAR(8000)
SELECT @Output = COALESCE(@Output+ @ConString, '') + CONVERT(varchar(20), Code)
FROM dbo.[Loclib5]
WHERE CodeLib4 = @Loclib4

RETURN @Output
END






Complicated things can be done by simple thinking
Go to Top of Page
   

- Advertisement -