I am cleaning some legacy data and have noticed there are individual in the Database twice with the same 9 digits in their social security number (SSN) but 2 of the digits are reversed, probably because of a keypunch error.
I am looking for a way to identify people with the same 9 digits, but 2 are reversed. Alternately, if this is too much of puzzle, identify the the same 9 digits and 7 of 9 are in the same order.
Below is some samlple code to populate a test db.
Notice the pairs SSNs that start wit 12, 34, 67 all contain the same 9 digits, but 2 are revesed.
12.. has the 67 reversed.
34.. has the 56 reversed
67.. has the 12 reversed
These sets of records I'd like to identify with code.
CREATE TABLE #temp (
[SSN] [varchar](9))
INSERT into #temp (ssn) values ('123456789')
INSERT into #temp (ssn) values ('123457689')
INSERT into #temp (ssn) values ('234567890')
INSERT into #temp (ssn) values ('345678901')
INSERT into #temp (ssn) values ('346578901')
INSERT into #temp (ssn) values ('456789012')
INSERT into #temp (ssn) values ('567890123')
INSERT into #temp (ssn) values ('678901234')
INSERT into #temp (ssn) values ('678902134')
INSERT into #temp (ssn) values ('789012345')
select * from #temp
-- drop table #temp
Jim
I am looking for a way to identify people with the same 9 digits, but 2 are reversed. Alternately, if this is too much of puzzle, identify the the same 9 digits and 7 of 9 are in the same order.
Below is some samlple code to populate a test db.
Notice the pairs SSNs that start wit 12, 34, 67 all contain the same 9 digits, but 2 are revesed.
12.. has the 67 reversed.
34.. has the 56 reversed
67.. has the 12 reversed
These sets of records I'd like to identify with code.
CREATE TABLE #temp (
[SSN] [varchar](9))
INSERT into #temp (ssn) values ('123456789')
INSERT into #temp (ssn) values ('123457689')
INSERT into #temp (ssn) values ('234567890')
INSERT into #temp (ssn) values ('345678901')
INSERT into #temp (ssn) values ('346578901')
INSERT into #temp (ssn) values ('456789012')
INSERT into #temp (ssn) values ('567890123')
INSERT into #temp (ssn) values ('678901234')
INSERT into #temp (ssn) values ('678902134')
INSERT into #temp (ssn) values ('789012345')
select * from #temp
-- drop table #temp
Jim