Thursday 16 August 2018

Get Comma separated all row for a single column using STUFF in sql server

///////////


Declare @Cols varchar(max)
SELECT  @Cols  = STUFF(( SELECT DISTINCT '],[' + LocationGUID from mstLocation where [Type]='WQ' ORDER BY '],[' +  LocationGUID FOR XML PATH('')), 1, 2, '') + ']'
select @Cols





No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...