Linked Questions

2451 votes
51 answers
3.4m views

How to concatenate text from multiple rows into a single text string in SQL Server

Consider a database table holding names, with three rows: Peter Paul Mary Is there an easy way to turn this into a single string of Peter, Paul, Mary?
JohnnyM's user avatar
  • 29.6k
113 votes
1 answer
472k views

Multiple rows to one comma-separated value in Sql Server [duplicate]

I want to create a table valued function in SQL Server, which I want to return data in comma separated values. For example table: tbl ID | Value ---+------- 1 | 100 1 | 200 1 | 300 1 | 400 ...
Sanjeev Singh's user avatar
49 votes
2 answers
75k views

What is the equivalent of String.Join on TSQL? [duplicate]

Possible Duplicate: Is there a way to create a SQL Server function to “join” multiple rows from a subquery into a single delimited field? Hi all! I'm looking for an easy way to ...
Gil's user avatar
  • 1,153
4 votes
2 answers
11k views

SQL Server join results as comma separated list [duplicate]

I have a company, industry, and company_industry_map many-to-many table. company_id | company_name 1 Goldman Sachs 2 Microsoft industry_id | industry 4 Technology ...
Adam Levitt's user avatar
  • 10.5k
1 vote
3 answers
4k views

Denormalize into pipe separated list [duplicate]

Possible Duplicate: Is there a way to create a SQL Server function to “join” multiple rows from a subquery into a single delimited field? I have a tablle like this: cust acc ---------...
dude j's user avatar
  • 23
1 vote
1 answer
4k views

sql concatenate multiple values [duplicate]

I have designed a view in SQL Server 2008 that displays 2 columns of distinct data in this format: Column1 Column2 A Text1 B Text2 B Text3 C Text4 D Text5 D Text6 ...
user2264507's user avatar
2 votes
1 answer
1k views

SQL Dynamic Column Query [duplicate]

Possible Duplicate: Is there a way to create a SQL Server function to "join" multiple rows from a subquery into a single delimited field? I have a table of "Events", and each event has a ...
MikeMurko's user avatar
  • 2,253
0 votes
3 answers
218 views

grouping based on name [duplicate]

How do i fetch the details of following table table1: c1 c2 ta a tb c ta b tb d by grouping with same name, like ta a,b tb c,d which function to use in ...
geek's user avatar
  • 836
0 votes
2 answers
644 views

Convert multiple rows into one with coma as separator [duplicate]

If I issue SELECT ID FROM TestAhmet I get this result: 1 3 5 2 4 but what I really need is one row with all the values separated by comma, like this: 1,2,3,4,5 How do I do this? ps: I cant do this :...
Ahmet Bulut's user avatar
-1 votes
2 answers
249 views

T-SQL: Combine rows to one row [duplicate]

I have the following table: number word ====== ==== 1 AAA 2 BBB 2 CCCC 4 CCCC 4 BBB 4 AAA Now I want to create a new table, where a "number" only occurs in one ...
uhu's user avatar
  • 1,742
0 votes
1 answer
89 views

return a string of comma delimited numbers from a sql query [duplicate]

How can I return a comma delimited string using SQL Server? select ID, (<<SomeQuery from TableB B where (B.Id = A.TableBId)>>) from TableA A and have it return results like: 1, '11, 12' ...
tzerb's user avatar
  • 1,433
-1 votes
2 answers
58 views

How would I write a T-SQL query to concatenate and group text [duplicate]

I have a table with the following structure: PERSON Sequence TEXT 1 1 John ran 1 2 across the field 2 1 Bill also 2 2 ran ...
user365853's user avatar
76 votes
8 answers
192k views

Concatenating Column Values into a Comma-Separated List

What is the TSQL syntax to format my output so that the column values appear as a string, seperated by commas. Example, my table CARS has the following: CarID CarName ---------------- 1 ...
Murali B's user avatar
  • 875
141 votes
4 answers
325k views

How to make a query with group_concat in sql server [duplicate]

I know that in sql server we cannot use Group_concat function but here is one issue i have in which i need to Group_Concat my query.I google it found some logic but not able to correct it.My sql query ...
Rahul's user avatar
  • 5,645
49 votes
2 answers
69k views

How do I concatenate strings from a subquery into a single row in MySQL?

I have three tables: table "package" ----------------------------------------------------- package_id int(10) primary key, auto-increment package_name varchar(255) price ...
mrbinky3000's user avatar
  • 4,391

15 30 50 per page
1
2 3 4 5