Linked Questions
16 questions linked to/from SQL Query - Concatenating Results into One String
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?
0
votes
0
answers
46
views
TSQL: How do I join a subsequence result? [duplicate]
Let's say I have these tables:
Table Persons:
ID Name
1 John
Table Groups:
ID Group
1 Admin
2 Printer
3 Server
Table PersonsAndGroups:
ID person_ID group_ID
1 ...
63
votes
11
answers
212k
views
How do I create a comma-separated list using a SQL query?
I have 3 tables called:
Applications (id, name)
Resources (id, name)
ApplicationsResources (id, app_id, resource_id)
I want to show on a GUI a table of all resource names. In one cell in each row I ...
76
votes
5
answers
102k
views
Can I Comma Delimit Multiple Rows Into One Column? [duplicate]
I am attempting to merge something like this in my SQL Server database:
[TicketID], [Person]
T0001 Alice
T0001 Bob
T0002 Catherine
T0002 Doug
T0003 Elaine
Into ...
85
votes
2
answers
100k
views
Does T-SQL have an aggregate function to concatenate strings? [duplicate]
Possible Duplicates:
Is there an Implode type function in SQL Server 2000?
How can I group fields from multiple records in T-SQL by another field?
I have a view which I'm querying that looks like this:...
12
votes
3
answers
101k
views
How to concat many rows into one string in SQL Server 2008? [duplicate]
How to concat many rows into one strings?
Query:
SELECT name FROM mytable;
Result:
name
----
kim
lee
park
cho
Just I want.
name
----
kim,lee,park,cho
Impossible?
6
votes
3
answers
11k
views
How to pivot unknown number of columns & no aggregate in SQL Server?
I have query which returns clients loans with associated collateral names like below (1)
but I want to have only one distinct loan number in a row and collateral names aside like on other example (2). ...
4
votes
3
answers
17k
views
Print bullet before each sentence + new line after each sentence SQL
I have a text like: Sentence one. Sentence two. Sentence three.
I want it to be:
Sentence one.
Sentence two.
Sentence three.
I assume I can replace '.' with '.' + char(10) + char(13), but how can I ...
1
vote
1
answer
498
views
How to return an string with concatenate values into an field (SQL script)
This SQL Server stored procedure returns a string with values delimited by single commas and placing an apostrophe before each value. Uses a table named Sucursal and returns an string with all ...
4
votes
1
answer
92
views
Get SQL Server's constraints list without redundancy
With this query I get the list of all my database's CHECK, FOREIGN_KEY, PRIMARY_KEY and UNIQUE_KEY constraints.
SELECT
o.object_id as ID, o.name AS Name,
OBJECT_NAME(o.parent_object_id) AS ...
0
votes
2
answers
106
views
SQL Server 2008R2 Custom Function so slow
Here is my function:
-- DECLARE @cur CURSOR
DECLARE @line int
declare @return varchar(255)
DECLARE myCursor CURSOR FOR
SELECT DISTINCT (quote_ln_no) as quote_ln_no
FROM dbo.quote_line_bom
WHERE ...
0
votes
0
answers
133
views
Comma-separated values with SQL query [duplicate]
Possible Duplicate:
Sql select group by and string concat
My SQL table looks like this:
City_Code Post_Code Post_Code_Description
100 A1 ABC
100 C8 ...
0
votes
1
answer
107
views
SQL How to add values of a select statement to a varchar
I'm writing a function that returns the names of a child table's one column's values in one varchar.
The relation is:
I have a parent table called Activity.
And a child table in N-1 relation with ...
0
votes
2
answers
64
views
MySQL: How to join three tables in one query with an assign table?
I have three tables:
ITEMS
itemid | itemname
1 | Item 1
FEATURES
featureid | featurename
1 | feature1
2 | feature2
3 | feature3
4 | feature4
... | ...
...
0
votes
2
answers
58
views
Need Oracle Query to Retrieve info from tables with 1 to Many Relationship
I have tables with information similar to the following:
Table A is a list of circuits:
Circuit | CktType | CktSize
--------------------------------
CKT1 | ABC123 | 10
CKT2 | ABC123 ...