Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

How can I return all results for one record in SQL?

$
0
0

In SQL 2017 there is a keyword for this (STRING_AGG) that does exactly what I want. Unfortunately, I am not in SQL 2017.

Basically, I want to search a table that has tasks related to incidents. For each Incident ID there can be any number of unique tasks. I want to return a single record that has all the incident information and a concatenated list of each of the task definitions for that particular incident. In the table, each task is a separate row so I just need to figure out how to group them by the Incident ID and have the definitions concatenated in a single string - without using the convenient String_Agg function that would be super handy right now...


Viewing all articles
Browse latest Browse all 4871

Trending Articles