Sunday, 31 March 2013

How to parse comma delimited string into IN Clause in SQL Server

declare @commasepvalue varchar(50)='rashmi,ashish,punit,vishal'

select q2.value from

(SELECT cast('<x>'+replace(@commasepvalue,',','</x><x>')+'</x>' as xml) as thexml)q1 CROSS APPLY

(SELECT x.value('.','varchar(100)') as value FROM thexml.nodes('x') as f(x))q2

 
and Output will be----

The Zero Trust Methodology

 Zero Trust (ZT) is a cybersecurity approach based on the principle “Never Trust, Always Verify.” It assumes that no user, device, or resour...