Hi @ahmed salah ,
I added t1 and found a solution, please refer to:
Create table #Ref
(
SignatureKey nvarchar(50),
GroupId int,
PortionKey nvarchar(50),
Status nvarchar(100)
)
insert into #Ref (SignatureKey, GroupId, PortionKey, status)
values
('*$**$*$***$**t$**$*', 5, '1t', NULL),
('*$g**$*$***$***$**$*', 2, 'g1', NULL),
('*$**$*$***$**t$**$*', 5, 't', NULL),
('*$**$*$***$*t$**$*', 5, 't', NULL),
('*$**$*$***$*t*$**$*', 5, '1t1', NULL),
('*$**$*$***$*t*$**$*', 5 , 't1' ,Null)
update r
set r.Status= 'Match Characters'
from #Ref r
cross apply
dbo.Split(r.SignatureKey,'$') f
where CAST (r.GroupId AS INT) = f.Id and charindex('*',f.data)>0
and (right(f.data,1)=right(r.PortionKey,1) or left(f.data,1)=left(r.PortionKey,1) or r.PortionKey like '[0-1]%[0-1]')
select * from #Ref
drop table #Ref
Best Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.