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
 General SQL Server Forums
 New to SQL Server Programming
 COMMA SEPRATED

Author  Topic 

yaman
Posting Yak Master

213 Posts

Posted - 2009-10-01 : 06:32:53
Sir ,

I want distinct comma seprated string using table data .I am using Coalesce function .

SELECT @id=Coalesce(@ID + ', ', '') + Cast(tli_po_no AS Nvarchar(50)) FROM contract_header,contract_detail
WHERE contract_header.contract_code=contract_detail.contract_code and shipvia_code=@SHIP_VIA_CODE

This query give me repeated records .
Problem is I do not want repeated records ,
I want only distinct records .

Pls help me out sir .

Yaman

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-01 : 06:38:12
[code]SELECT DISTINCT @id=Coalesce(@ID + ', ', '') + Cast(tli_po_no AS Nvarchar(50)) FROM contract_header,contract_detail
WHERE contract_header.contract_code=contract_detail.contract_code and shipvia_code=@SHIP_VIA_CODE
[/code]
Go to Top of Page
   

- Advertisement -