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

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...