Hi,I have to check data in ctcode_desc to find the wrong data.
The logic of the input in ctcode_desc is 'number, single space, - sign, single space, text'.
The logic of the input in ctcode is number&character.
Data will be wrong If data doesn't follow the rule of data in ctcode_desc or ctcode column . Please help in query to find the wrong data in ctcode_desc.
create table #ctcode(ctcode char(4),ctcode_desc char(40))
insert into #ctcode values ('01TRST','1 - TRSTEmployee')
insert into #ctcode values ('02URBN','2- URBN Employee') --Wrong data because single space is missing after number in ctcode_desc.
insert into #ctcode values ('09VILL','9 - VILL Employee')
insert into #ctcode values ('10SERT','10 - SERT Employee')
insert into #ctcode values ('11FULL','11 -FULL Employee') --Wrong data because single space is missing after dash sign in ctcode_desc.
insert into #ctcode values ('12TEMP','12 - TEMP Employee')
insert into #ctcode values ('13PART','13 - PART Employee')
insert into #ctcode values ('14CONT','14-CONT Employee') --Wrong data because single space is missing after number and dash sign in ctcode_desc.
insert into #ctcode values ('03ASST','03 - ASTT Employee') --Wrong data because number has '03'. It should be '3' in ctcode_desc.
insert into #ctcode values ('04DSTT','4 - DSTT Employee')
insert into #ctcode values ('8DSPP','8 - DSPP Employee') --Wrong data because '08DSTT' should be in ctcode instead '8DSTT'
--Desired result which has wrong data
Select * from #ctcode
ctcode ctcode_desc
02URBN 2- URBN Employee
11FULL 11 -FULL Employee
14CONT 14-CONT Employee
03ASST 03 - ASTT Employee
8DSPP 8 - DSPP Employee