| Author |
Topic |
|
asuni
Yak Posting Veteran
55 Posts |
Posted - 2010-04-01 : 00:45:02
|
| Hi All,I had one table with one column.that table had 10 rows.I want one select query to select all the column data in one row with comma seperated.thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
asuni
Yak Posting Veteran
55 Posts |
Posted - 2010-04-01 : 01:00:21
|
| ok, thanks i will check |
 |
|
|
asuni
Yak Posting Veteran
55 Posts |
Posted - 2010-04-01 : 05:48:24
|
| Hi,what i want is:my table structure isname-------name1name2name3name4name5i had a table with one column and data like this.but i want the output as:name1, name2, name3, name4, name5is it possible with query.i did with cursor, but i have to do with query.thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-01 : 06:03:09
|
| [code]SELECT STUFF(u.v,1,1,'')FROM(SELECT ',' + name FROM @t FOR XML PATH(''))u(v)output--------------name1,name2,name3,name4,name5[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
asuni
Yak Posting Veteran
55 Posts |
Posted - 2010-04-01 : 06:23:50
|
| so nice,thank you very muchthis only i want |
 |
|
|
asuni
Yak Posting Veteran
55 Posts |
Posted - 2010-04-01 : 06:28:40
|
| can you pls explain this, i mean what is u(v) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-01 : 07:41:24
|
quote: Originally posted by asuni can you pls explain this, i mean what is u(v)
they represent table column aliases------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
asuni
Yak Posting Veteran
55 Posts |
Posted - 2010-04-01 : 07:47:00
|
| ok, thank you very much, you are genius. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-01 : 12:04:47
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|