I work with SQL Server 2012 and I have an issue: I can't update status to match characters where signature key have stars *
.
I need to update status to match characters where signature key have starts as example
Signature Key Group Id Portion Key Status
*$*$**s$***$**$**$* 3 12s Match Characters
group id 3 from signature key above is **s must equal portion key (12s) so status must be match characters.
But if group id value is **f and portion key value is 15g then it will be Not Match Character status
Because g
is not equal to f
.
Create table #Ref
(
SignatureKey nvarchar(50),
GroupId int,
PortionKey nvarchar(50),
Status nvarchar(100)
)
insert into #Ref (SignatureKey, GroupId, PortionKey, status)
values ('*$*$C$***$**$**$*', 3, 's', NULL),
('*$*$*$FG$*$**$*', 4, 'F', NULL),
('*$*$*$***$*$D$*', 6, 'D', NULL),
('*$t**$*$***$***$**$*', 2, 't12', NULL),
('*$**$*$***$**t$**$*', 5, '12t', NULL)
update r
set r.Status = 'Not Match Charachters'
from #Ref r
cross apply
dbo.Split(r.SignatureKey,'$') f where CAST (r.GroupId AS INT) = f.Id and r.PortionKey <> f.Data
Expected result :
Signature Key Group Id Portion Key Status
*$*$C$***$**$**$* 3 s Not Match Characters
*$*$*$FG$*$**$* 4 F Not Match Characters
*$*$*$***$*$D$* 6 D Not Match Characters
*$t**$*$***$***$**$* 2 t12 Match Characters
*$**$*$***$**t$**$* 5 12t Match Characters
what I need to say is status with be Match characters in case of signature key value equal to portion key
exactly as (c = c) or signature key have stars on group id so i will ignore starts * and compare
character with character as (*f = 1f) meaning if i have stars then ignore compare with character.
Last Updated post :
dbo.split function exist on
https://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648
also group id represent number of portion from signature key suppose i have signature key ;
*$*c$C$**$***$5*$6*
then from left to right :
group id 1 value = *
group id 2 value = *c
group id 3 value = c
group id 4 value = **
group id 5 value = ***
group id 6 value = 5*
group id 7 value = 6*
group_id
in the query you have shown is unclear. Isgroup_id
an artificial unique key or does its value have a meaning? – Ed Harper Sep 8 '20 at 9:03dbo.Split
to the question – Ed Harper Sep 8 '20 at 9:03*$*$*$***$*$D$*
) not a match forD
? – Sander Sep 8 '20 at 11:00