sql - How to compare two comma-separated strings, and return false untill and unless all values matched -
sql - How to compare two comma-separated strings, and return false untill and unless all values matched -
suppose @v1 = p1;p2;p3;p4 @v2 = p1;p2;p3 @v3= p1;p2;p3;p4
i have compare values of @v2 , @v3 values of @v1. need function homecoming true if there match of values . in above example, homecoming true in case of @v3 , returns false in case of @v2.
i trying write code..but not working. mentioning code here.
select case when exists ( select 1 dbo.split(@v1) inner bring together dbo.split(@v2) b on a.item = b.item ) 1 else 0 end; how can possible in sql server? plz help.
for value match can go equal operator:
declare @v1 varchar(20) = 'p1;p2;p3;p4' declare @v2 varchar(20) = 'p1;p2;p3' declare @v3 varchar(20) = 'p1;p2;p3;p4' if @v1 = @v2 print 'v1=v2' else if @v1 = @v3 print 'v1=v3' if exists(select 1 dbo.split(@v1) inner bring together dbo.split(@v2) b on a.item = b.item) select 1 else select 0
assuming function table valued.
sql sql-server
Comments
Post a Comment