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

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