Friday, 19 April 2019

Get data with comma separated string from table using sql server

/////////////


DECLARE @StrClm varchar(50)
set @StrClm='1,2,3,4,5,6,7'
DECLARE @ListStr VARCHAR(MAX),@Ids varchar(50) = ''
set @Ids=','+@StrClm+','
SELECT @ListStr = COALESCE(@ListStr+',' ,'') + Description FROM mst_990Lookup where LookupFlag=36 and Charindex(','+cast(LookupCode as varchar(8000))+',', @Ids) > 0 --and Flag=1

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...