Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering Rogue Chars

Status
Not open for further replies.
Joined
Oct 17, 2006
Messages
227
HI

I was wondering if there is any way of filtering out rogue chars the only thing is that has to be considered is a double barrelled name Peter-Paul Thomas.

FirstName Surname
Peter Èajèyc Thomas


Many Thanks

Robert


 
HI Markos

That doesn't work

ie if you have

FirstName Surname
Peter Èajèyc Thomas
Peter Mason
Brad-Jones Smith

and use the select * from myTable where myField like'%[0-9a-z]% it picks up all 3 instead of the first record.

 
Code:
DECLARE @Test TABLE (MyField nvarchar(200))
INSERT INTO @Test VALUES (N'Peter Èajèyc  Thomas')
INSERT INTO @Test VALUES (N'Peter           Mason')
INSERT INTO @Test VALUES (N'Brad-Jones      Smith')
           
           
select * from @Test where myField like '%^[0-9a-zA-Z]%'

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Hi Boris

If I do as stated


DECLARE @Test TABLE (MyField nvarchar(200))
INSERT INTO @Test VALUES (N'Peter Èajèyc Thomas')
INSERT INTO @Test VALUES (N'Peter Mason')
INSERT INTO @Test VALUES (N'Brad-Jones Smith')

select * from @Test where myField like '%^[0-9a-zA-Z]%'

it doesn't bring up Peter it brings nothing. I need to try and trap Peter.

Thanks



 
Code:
DECLARE @Test TABLE (MyField nvarchar(200))
INSERT INTO @Test VALUES (N'Peter Èajèyc  Thomas')
INSERT INTO @Test VALUES (N'Peter           Mason')
INSERT INTO @Test VALUES (N'Brad-Jones      Smith')                      

select * from @Test where myField COLLATE Cyrillic_General_CI_AI like '%^[0-9a-zA-Z]%'

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
If I understand correctly, firstname and surname are two fields(?). Suppose the filter is restricted on the firstname, you can do this?
[tt]
select * from [blue]tablename[/blue] where FirstName not like '%[^0-9a-zA-Z\-]%'
[/tt]
The filter is still quite loose and not very restrictive. (For instance, it allows "PeterPaul-" which is not quite correct as a first name.)
 
Yeah,
that was my first thought, but all the records are LIKE '%[0-9a-zA-Z]%'
Just because every record has at least one English char.

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top