I work on sql server 2019 i have issue i can't get percentage of two string from table
so i will compare between two string columns (PartText,MaskText)
and i will display similar percentage of two column
so as sample 'TR00123907FG','KB00123907FG' two string different only on first two charachters
so difference will be 80 percent
create table #compareTextPercentage
(
PartText varchar(50),
MaskText varchar(50)
)
insert into #compareTextPercentage(PartText,MaskText)
values
('TR00123907FG','KB00123907FG'),
('TR00123907FG','TR00123907FG'),
('klmhedf43122','50ghlpnkyzhy')
expected result
What I have tried:
i try using difference but not give me accurate result
DECLARE @tbl table (ID INT IDENTITY PRIMARY KEY, PartText varchar(50), MaskText varchar(50));
INSERT INTO @tbl (PartText,MaskText) VALUES
('TR00123907FG','KB00123907FG'),
('TR00123907FG','TR00123907FG'),
('klmhedf43122','50ghlpnkyzhy');
SELECT *
, Diff = DIFFERENCE(PartText, MaskText) * 25
FROM @tbl;