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.
| Author |
Topic |
|
ajay
Starting Member
34 Posts |
Posted - 2004-08-18 : 18:24:22
|
| Hello Gurus,I have a table whose structure is like thisColumn A ColumnBA TB TB XA XA YB YUsing Some query I want to return record in a string formatsomething like A;B for column A and T;X;Y for column B With out using Two temporary table for each column.I tried using CoalESC function but it gives A;B;B;A;A;B etc. As you can see I need distinct values in my string..Sincerlyajay |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2004-08-18 : 18:36:47
|
| Use use "DISTINCT" to get values only once and "ORDER BY" to get it sortedmk_garg |
 |
|
|
ajay
Starting Member
34 Posts |
Posted - 2004-08-18 : 19:06:16
|
quote: Originally posted by mk_garg20 Use use "DISTINCT" to get values only once and "ORDER BY" to get it sortedmk_garg
For Column A in a string I usedSELECT @ColA=COALESCE(@ColA+'','')+ ColumnA from TableWhere do i use distinct here?ThanksAjayajay |
 |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-08-18 : 19:29:38
|
| Have a look at the following article:http://www.sqlteam.com/item.asp?ItemID=11021 |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2004-08-19 : 02:14:26
|
| Try this SELECT @ColA=COALESCE(@ColA+'','')+ ColumnA from (SELECT DISTINCT columnA from Table) Amk_garg |
 |
|
|
|
|
|