Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Creating a delimited string

$
0
0
Hi All, I have a need to create a delimited string so that I can use this to create a data driven subscription on SSRS, I am pretty sure I am making a fairly simple task a lot harder than it needs to be here.In the below code, I need to create a delimited string using the branch number, grouped by the email address[code="sql"]USE tempdbGO IF OBJECT_ID('tempdb..#emails') IS NOT NULL BEGIN DROP TABLE #emails END CREATE TABLE #emails ( Email VARCHAR(50) , BranchNumber VARCHAR(5) )INSERT INTO #emailsVALUES ( 'Branch101@ACA.com', 'A54' ), ( 'Branch101@ACA.com', 'A56' ), ( 'Branch101@ACA.com', 'A59' ), ( 'Branch102@ACA.com', 'B49' ), ( 'Branch102@ACA.com', 'B54' ), ( 'Branch102@ACA.com', 'B10' ), ( 'Branch103@ACA.com', 'C80' )[/code]The output I am looking for is something along the lines of...Email, BranchNumber----------------------------------------------------------Branch101@ACA.com A54,A56,A59Branch102@ACA.com B49,B54,B10Branch103@ACA.com C80ThanksJim

Viewing all articles
Browse latest Browse all 3145

Trending Articles