Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 French Characters in the field

Author  Topic 

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2012-08-08 : 10:38:35
I want to find all the records where a column has French (accented) characters in it.

The field is varchar and it has data which contains French Characters.

Tried the following and many more combinations


SELECT * FROM Addresses WHERE Address_1 not LIKE '%[^a-z,A-Z]%'
SELECT * FROM Addresses WHERE Address_1 not LIKE '%[^a-zA-Z]%'
SELECT * FROM Addresses WHERE Address_1 LIKE '%[^a-z,A-Z]%'
SELECT * FROM Addresses WHERE Address_1 LIKE '%[a-z,A-Z]%'
.................

I can query and get the results as follows
SELECT Address_1, cast(Address_1 as varchar(100)) COLLATE SQL_Latin1_General_CP1253_CI_AI as convertedAddress FROM Addresses WHERE  Address_ID IN (27,28)

Result:

Address_1 convertedAddress
1234 boul de la Métropole 1234 boul de la Metropole
5678 rue Bériault 5678 rue Beriault


But doesn't work for

SELECT * FROM Addresses WHERE convert(VARCHAR(1000), Address_1) != cast(Address_1 as nvarchar(1000)) COLLATE SQL_Latin1_General_CP1253_CI_AI


Srinika

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-08 : 10:44:11
take uncode values of french characters in a table and search using them

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2012-08-08 : 11:43:25
Hi Visakh,

Thanks for the reply.
You mean Unicode values? How do I get those?
The Search is to check character by character in the field using a function like substring? It may take a long time isn't it?

Srinika
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-08 : 14:17:09
see this example illustration


declare @FrenchChars table
(
id int,
FrChr nchar(1)
)
insert into @FrenchChars
select REPLACE(m,';',''),n
from
(
values
('224;','à'),
('194;','Â'),
('226;','â'),
('198;','Æ'),
('230;','æ'),
('199;','Ç'),
('231;','ç'),
('200;','È'),
('232;','è'),
('201;','É'),
('233;','é'),
('202;','Ê'),
('234;','ê'),
('203;','Ë'),
('235;','ë'),
('206;','Î'),
('238;','î'),
('207;','Ï'),
('239;','ï'),
('212;','Ô'),
('244;','ô'),
('140;','Œ'),
('156;','œ'),
('217;','Ù'),
('249;','ù'),
('219;','Û'),
('251;','û'),
('220;','Ü'),
('252;','ü'),
('171;','«'),
('187;','»'),
('128;','€'),
('8355;','?')
)t(m,n)


--select * from @FrenchChars


declare @tbl table

(Address_1 varchar(1000),
convertedAddress varchar(1000)
)

insert @tbl
values('1234 boul de la Métropole', '1234 boul de la Metropole'),
('5678 rue Bériault','5678 rue Beriault')


select *
from @tbl t
where exists(select 1
from @FrenchChars
where t.Address_1 LIKE '%' + FrChr + '%'
)

output
-------------------------------------------
Address_1 convertedAddress
1234 boul de la Métropole 1234 boul de la Metropole
5678 rue Bériault 5678 rue Beriault



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2012-08-08 : 15:32:25
Excellent!
Works
Thanks Visakh

Srinika
Go to Top of Page
   

- Advertisement -