This is a discussion on Concatenate row values in a table within the Database Support forums, part of the Web Development category; Hi, I want to concatenate row values in a table using select statement in MS SQL. For. e.g Sl. ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, I want to concatenate row values in a table using select statement in MS SQL. For. e.g Sl. Name -- ------ 1 Jack 2 Paul 3 Philip Using a select statement we should get the following output. Jack,Paul,Philip can anyone tell me is it possible? Thanks
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... Last edited by oxygen : 02-07-2008 at 10:36 PM. |
| Sponsored Links |
| |||
| hi.. oxy.... yeah.. its possible Please try the following query Here I followed 2 steps for concatenating row values... First, we can get the result using "for xml raw" then, we convert it as varchar... declare @cols varchar(1000) select @cols = CAST ((select filedname as col1 FROM tablename for xml raw, elements, type).query('for $col1 in (row/col1) return concat($col1, ",")') as varchar(1000)) select @cols I hope it will help you |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Export table values into excel | oxygen | C# Programming | 2 | 03-18-2008 02:13 AM |
| How to concatenate strings with Perl? | amansundar | Perl | 3 | 11-28-2007 09:39 PM |
| How to get values from querystring? | S.Vinothkumar | Ruby | 2 | 11-26-2007 06:40 AM |
| What is the difference between DELETE TABLE and TRUNCATE TABLE commands in SQL Server | oxygen | Database Support | 6 | 11-23-2007 06:17 AM |
| When designing a database table, how do you avoid missing column values for non-prima | Arun | Database Support | 2 | 07-18-2007 10:43 PM |