J'ai une question concernant les accents.
Je fais des requêtes dans une BD avec des opérateurs LIKE.
ex: SELECT * FROM TABLE WHERE nom LIKE '%Belanger%'
Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger" dans
ma table. Le résultat de cette requête me retourne seulement les "Belanger"
sans accent.
Y a-t-il un moyen pour que mon LIKE ignore les accents?
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Zoury
hug! :O)
tu pourrais organiser ton masque comme ceci : --- SELECT * FROM TABLE WHERE nom LIKE '%B[ée]langer%' --- sauf que ce n'est pas très pratique...
tu pourrais donc faire une fonction qui te renvoit une version non accentué d'un chaine donnée..
ex : --- CREATE FUNCTION [dbo].[fn_FrenchAccentRemover] ( @in varchar(8000) ) RETURNS varchar(8000) AS BEGIN
declare @i int declare @c char(1) declare @ascii int declare @out varchar(8000)
set @i = 1 set @out = ''
while (@i <= len(@in)) begin set @c = substring(@in, @i, 1) set @ascii = ascii(@c)
set @c case when @ascii in (192, 193, 194, 195, 196, 197) then 'A' when @ascii in (224, 225, 226, 227, 228, 229) then 'a' when @ascii in (200, 201, 202, 203) then 'E' when @ascii in (232, 233, 234, 235) then 'e' when @ascii in (204, 205, 206, 207) then 'I' when @ascii in (236, 237, 238, 239) then 'i' when @ascii in (210, 211, 212, 213, 214) then 'O' when @ascii in (242, 243, 244, 245, 246) then 'o' when @ascii in (217, 218, 219, 220) then 'U' when @ascii in (249, 250, 251, 252) then 'u' when @ascii in (253, 255) then 'y' when @ascii = 221 then 'Y' when @ascii = 199 then 'C' when @ascii = 231 then 'c' else @c end
set @out = @out + @c set @i = @i + 1 end
return @out
END ---
tu l'utiliserais ainsi : --- SELECT * FROM TABLE WHERE dbo.fn_FrenchAccentRemover(nom) LIKE '%Belanger%' ---
Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger"
dans
ma table. Le résultat de cette requête me retourne seulement les
"Belanger"
sans accent.
Y a-t-il un moyen pour que mon LIKE ignore les accents?
Merci de votre aide!
hug! :O)
tu pourrais organiser ton masque comme ceci :
---
SELECT * FROM TABLE WHERE nom LIKE '%B[ée]langer%'
---
sauf que ce n'est pas très pratique...
tu pourrais donc faire une fonction qui te renvoit une version non accentué
d'un chaine donnée..
ex :
---
CREATE FUNCTION [dbo].[fn_FrenchAccentRemover]
(
@in varchar(8000)
)
RETURNS varchar(8000) AS
BEGIN
declare @i int
declare @c char(1)
declare @ascii int
declare @out varchar(8000)
set @i = 1
set @out = ''
while (@i <= len(@in))
begin
set @c = substring(@in, @i, 1)
set @ascii = ascii(@c)
set @c case
when @ascii in (192, 193, 194, 195, 196, 197) then 'A'
when @ascii in (224, 225, 226, 227, 228, 229) then 'a'
when @ascii in (200, 201, 202, 203) then 'E'
when @ascii in (232, 233, 234, 235) then 'e'
when @ascii in (204, 205, 206, 207) then 'I'
when @ascii in (236, 237, 238, 239) then 'i'
when @ascii in (210, 211, 212, 213, 214) then 'O'
when @ascii in (242, 243, 244, 245, 246) then 'o'
when @ascii in (217, 218, 219, 220) then 'U'
when @ascii in (249, 250, 251, 252) then 'u'
when @ascii in (253, 255) then 'y'
when @ascii = 221 then 'Y'
when @ascii = 199 then 'C'
when @ascii = 231 then 'c'
else @c
end
set @out = @out + @c
set @i = @i + 1
end
return @out
END
---
tu l'utiliserais ainsi :
---
SELECT * FROM TABLE WHERE dbo.fn_FrenchAccentRemover(nom) LIKE '%Belanger%'
---
tu pourrais organiser ton masque comme ceci : --- SELECT * FROM TABLE WHERE nom LIKE '%B[ée]langer%' --- sauf que ce n'est pas très pratique...
tu pourrais donc faire une fonction qui te renvoit une version non accentué d'un chaine donnée..
ex : --- CREATE FUNCTION [dbo].[fn_FrenchAccentRemover] ( @in varchar(8000) ) RETURNS varchar(8000) AS BEGIN
declare @i int declare @c char(1) declare @ascii int declare @out varchar(8000)
set @i = 1 set @out = ''
while (@i <= len(@in)) begin set @c = substring(@in, @i, 1) set @ascii = ascii(@c)
set @c case when @ascii in (192, 193, 194, 195, 196, 197) then 'A' when @ascii in (224, 225, 226, 227, 228, 229) then 'a' when @ascii in (200, 201, 202, 203) then 'E' when @ascii in (232, 233, 234, 235) then 'e' when @ascii in (204, 205, 206, 207) then 'I' when @ascii in (236, 237, 238, 239) then 'i' when @ascii in (210, 211, 212, 213, 214) then 'O' when @ascii in (242, 243, 244, 245, 246) then 'o' when @ascii in (217, 218, 219, 220) then 'U' when @ascii in (249, 250, 251, 252) then 'u' when @ascii in (253, 255) then 'y' when @ascii = 221 then 'Y' when @ascii = 199 then 'C' when @ascii = 231 then 'c' else @c end
set @out = @out + @c set @i = @i + 1 end
return @out
END ---
tu l'utiliserais ainsi : --- SELECT * FROM TABLE WHERE dbo.fn_FrenchAccentRemover(nom) LIKE '%Belanger%' ---
Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger"
dans
ma table. Le résultat de cette requête me retourne seulement les
"Belanger"
sans accent.
Y a-t-il un moyen pour que mon LIKE ignore les accents?
Merci de votre aide!
+The_Taco+
Merci! J'y jette un coup d'oeil!-
"Zoury" a écrit dans le message de news:
hug! :O)
tu pourrais organiser ton masque comme ceci : --- SELECT * FROM TABLE WHERE nom LIKE '%B[ée]langer%' --- sauf que ce n'est pas très pratique...
tu pourrais donc faire une fonction qui te renvoit une version non
accentué
d'un chaine donnée..
ex : --- CREATE FUNCTION [dbo].[fn_FrenchAccentRemover] ( @in varchar(8000) ) RETURNS varchar(8000) AS BEGIN
declare @i int declare @c char(1) declare @ascii int declare @out varchar(8000)
set @i = 1 set @out = ''
while (@i <= len(@in)) begin set @c = substring(@in, @i, 1) set @ascii = ascii(@c)
set @c > case when @ascii in (192, 193, 194, 195, 196, 197) then 'A' when @ascii in (224, 225, 226, 227, 228, 229) then 'a' when @ascii in (200, 201, 202, 203) then 'E' when @ascii in (232, 233, 234, 235) then 'e' when @ascii in (204, 205, 206, 207) then 'I' when @ascii in (236, 237, 238, 239) then 'i' when @ascii in (210, 211, 212, 213, 214) then 'O' when @ascii in (242, 243, 244, 245, 246) then 'o' when @ascii in (217, 218, 219, 220) then 'U' when @ascii in (249, 250, 251, 252) then 'u' when @ascii in (253, 255) then 'y' when @ascii = 221 then 'Y' when @ascii = 199 then 'C' when @ascii = 231 then 'c' else @c end
set @out = @out + @c set @i = @i + 1 end
return @out
END ---
tu l'utiliserais ainsi : --- SELECT * FROM TABLE WHERE dbo.fn_FrenchAccentRemover(nom) LIKE
'%Belanger%'
---
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic classique http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/ http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/ > > Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger" dans > ma table. Le résultat de cette requête me retourne seulement les "Belanger" > sans accent. > > Y a-t-il un moyen pour que mon LIKE ignore les accents? > > Merci de votre aide! > >
Merci!
J'y jette un coup d'oeil!-
"Zoury" <yanick_lefebvre@hotmail.com> a écrit dans le message de
news:u86csSjeEHA.3016@tk2msftngp13.phx.gbl...
hug! :O)
tu pourrais organiser ton masque comme ceci :
---
SELECT * FROM TABLE WHERE nom LIKE '%B[ée]langer%'
---
sauf que ce n'est pas très pratique...
tu pourrais donc faire une fonction qui te renvoit une version non
accentué
d'un chaine donnée..
ex :
---
CREATE FUNCTION [dbo].[fn_FrenchAccentRemover]
(
@in varchar(8000)
)
RETURNS varchar(8000) AS
BEGIN
declare @i int
declare @c char(1)
declare @ascii int
declare @out varchar(8000)
set @i = 1
set @out = ''
while (@i <= len(@in))
begin
set @c = substring(@in, @i, 1)
set @ascii = ascii(@c)
set @c > case
when @ascii in (192, 193, 194, 195, 196, 197) then 'A'
when @ascii in (224, 225, 226, 227, 228, 229) then 'a'
when @ascii in (200, 201, 202, 203) then 'E'
when @ascii in (232, 233, 234, 235) then 'e'
when @ascii in (204, 205, 206, 207) then 'I'
when @ascii in (236, 237, 238, 239) then 'i'
when @ascii in (210, 211, 212, 213, 214) then 'O'
when @ascii in (242, 243, 244, 245, 246) then 'o'
when @ascii in (217, 218, 219, 220) then 'U'
when @ascii in (249, 250, 251, 252) then 'u'
when @ascii in (253, 255) then 'y'
when @ascii = 221 then 'Y'
when @ascii = 199 then 'C'
when @ascii = 231 then 'c'
else @c
end
set @out = @out + @c
set @i = @i + 1
end
return @out
END
---
tu l'utiliserais ainsi :
---
SELECT * FROM TABLE WHERE dbo.fn_FrenchAccentRemover(nom) LIKE
'%Belanger%'
---
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic classique
http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/
http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/
>
> Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger"
dans
> ma table. Le résultat de cette requête me retourne seulement les
"Belanger"
> sans accent.
>
> Y a-t-il un moyen pour que mon LIKE ignore les accents?
>
> Merci de votre aide!
>
>
tu pourrais organiser ton masque comme ceci : --- SELECT * FROM TABLE WHERE nom LIKE '%B[ée]langer%' --- sauf que ce n'est pas très pratique...
tu pourrais donc faire une fonction qui te renvoit une version non
accentué
d'un chaine donnée..
ex : --- CREATE FUNCTION [dbo].[fn_FrenchAccentRemover] ( @in varchar(8000) ) RETURNS varchar(8000) AS BEGIN
declare @i int declare @c char(1) declare @ascii int declare @out varchar(8000)
set @i = 1 set @out = ''
while (@i <= len(@in)) begin set @c = substring(@in, @i, 1) set @ascii = ascii(@c)
set @c > case when @ascii in (192, 193, 194, 195, 196, 197) then 'A' when @ascii in (224, 225, 226, 227, 228, 229) then 'a' when @ascii in (200, 201, 202, 203) then 'E' when @ascii in (232, 233, 234, 235) then 'e' when @ascii in (204, 205, 206, 207) then 'I' when @ascii in (236, 237, 238, 239) then 'i' when @ascii in (210, 211, 212, 213, 214) then 'O' when @ascii in (242, 243, 244, 245, 246) then 'o' when @ascii in (217, 218, 219, 220) then 'U' when @ascii in (249, 250, 251, 252) then 'u' when @ascii in (253, 255) then 'y' when @ascii = 221 then 'Y' when @ascii = 199 then 'C' when @ascii = 231 then 'c' else @c end
set @out = @out + @c set @i = @i + 1 end
return @out
END ---
tu l'utiliserais ainsi : --- SELECT * FROM TABLE WHERE dbo.fn_FrenchAccentRemover(nom) LIKE
'%Belanger%'
---
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic classique http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/ http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/ > > Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger" dans > ma table. Le résultat de cette requête me retourne seulement les "Belanger" > sans accent. > > Y a-t-il un moyen pour que mon LIKE ignore les accents? > > Merci de votre aide! > >
Zoury
> J'y jette un coup d'oeil!-
Si tu veux... mais utilise quand même la technique qu'ils t'ont offert sur le groupe anglophone. c'est *vraiment* plus efficace.. ;O)
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic classque Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
> J'y jette un coup d'oeil!-
Si tu veux... mais utilise quand même la technique qu'ils t'ont offert sur
le groupe anglophone. c'est *vraiment* plus efficace.. ;O)
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic classque
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
Si tu veux... mais utilise quand même la technique qu'ils t'ont offert sur le groupe anglophone. c'est *vraiment* plus efficace.. ;O)
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic classque Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
+The_Taco+
Hehe! Je m'en allais te proposer cette technique!
Merci encore!
"Zoury" a écrit dans le message de news:
> J'y jette un coup d'oeil!-
Si tu veux... mais utilise quand même la technique qu'ils t'ont offert sur le groupe anglophone. c'est *vraiment* plus efficace.. ;O)
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic classque Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Hehe!
Je m'en allais te proposer cette technique!
Merci encore!
"Zoury" <yanick_lefebvre@hotmail.com> a écrit dans le message de
news:eRNnTAkeEHA.4068@TK2MSFTNGP11.phx.gbl...
> J'y jette un coup d'oeil!-
Si tu veux... mais utilise quand même la technique qu'ils t'ont offert sur
le groupe anglophone. c'est *vraiment* plus efficace.. ;O)
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic classque
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
Si tu veux... mais utilise quand même la technique qu'ils t'ont offert sur le groupe anglophone. c'est *vraiment* plus efficace.. ;O)
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic classque Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Fred BROUARD
jouer sur les collations....
A lire : http://sqlpro.developpez.com/MSSQLServer_collations/Collations.html
A +
+The_Taco+ a écrit:
Bonjours à tous!
J'ai une question concernant les accents. Je fais des requêtes dans une BD avec des opérateurs LIKE.
ex: SELECT * FROM TABLE WHERE nom LIKE '%Belanger%'
Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger" dans ma table. Le résultat de cette requête me retourne seulement les "Belanger" sans accent.
Y a-t-il un moyen pour que mon LIKE ignore les accents?
Merci de votre aide!
-- Frédéric BROUARD, MVP SQL Server. Expert SQL / spécialiste Delphi, web Livre SQL - col. Référence : http://sqlpro.developpez.com/bookSQL.html Le site du SQL, pour débutants et pros : http://sqlpro.developpez.com ************************ www.datasapiens.com *************************
jouer sur les collations....
A lire : http://sqlpro.developpez.com/MSSQLServer_collations/Collations.html
A +
+The_Taco+ a écrit:
Bonjours à tous!
J'ai une question concernant les accents.
Je fais des requêtes dans une BD avec des opérateurs LIKE.
ex: SELECT * FROM TABLE WHERE nom LIKE '%Belanger%'
Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger" dans
ma table. Le résultat de cette requête me retourne seulement les "Belanger"
sans accent.
Y a-t-il un moyen pour que mon LIKE ignore les accents?
Merci de votre aide!
--
Frédéric BROUARD, MVP SQL Server. Expert SQL / spécialiste Delphi, web
Livre SQL - col. Référence : http://sqlpro.developpez.com/bookSQL.html
Le site du SQL, pour débutants et pros : http://sqlpro.developpez.com
************************ www.datasapiens.com *************************
A lire : http://sqlpro.developpez.com/MSSQLServer_collations/Collations.html
A +
+The_Taco+ a écrit:
Bonjours à tous!
J'ai une question concernant les accents. Je fais des requêtes dans une BD avec des opérateurs LIKE.
ex: SELECT * FROM TABLE WHERE nom LIKE '%Belanger%'
Le problème qui se trouve est que j'ai des "Bélanger" et des "Belanger" dans ma table. Le résultat de cette requête me retourne seulement les "Belanger" sans accent.
Y a-t-il un moyen pour que mon LIKE ignore les accents?
Merci de votre aide!
-- Frédéric BROUARD, MVP SQL Server. Expert SQL / spécialiste Delphi, web Livre SQL - col. Référence : http://sqlpro.developpez.com/bookSQL.html Le site du SQL, pour débutants et pros : http://sqlpro.developpez.com ************************ www.datasapiens.com *************************