En fonction de la taille de votre ensemble de données, vous pouvez essayer le texte intégral (si c'est une option).
Vous pouvez créer un index de texte intégral sur les trois colonnes pouvant être recherchées, ce qui vous permet également d'interroger une colonne spécifique (ou une combinaison) si le besoin s'en faisait sentir - par ex. vous voulez des lignes où le texte de recherche existe dans [Description] seulement.
if object_id('dbo.ft_example') is not null drop table dbo.ft_example;
create table dbo.ft_example (
rowid int identity not null constraint pk_ft_example primary key,
[Word] varchar(100),
[Description] varchar(1000),
[Example] varchar(500)
);
insert dbo.ft_example ([Word], [Description], [Example])
select 'blah blah cat', 'blah blah blah blah blah blah blah blah bird', 'blah blah blah blah fish' union all
select 'blah blah dog', 'blah blah blah blah blah blah blah blah cat', 'blah blah blah blah horse' union all
select 'blah blah camel', 'blah blah blah blah blah blah blah blah squid', 'blah blah blah blah horse' union all
select 'blah blah horse', 'blah blah blah blah blah blah blah blah cat', 'blah blah blah blah moose' union all
select 'blah blah fish', 'blah blah blah blah blah blah blah blah whale', 'blah blah blah blah bird' union all
select 'blah blah camel', 'blah blah blah blah blah blah blah blah squirel', 'blah blah blah blah kiwi' union all
select 'blah blah kiwi', 'blah blah blah blah blah blah blah blah bird', 'blah blah blah blah horse';
if exists(
select *
from sys.fulltext_indexes
join sys.tables
on sys.tables.object_id = sys.fulltext_indexes.object_id
where sys.tables.name = 'ft_example'
)
drop fulltext index on ft_example;
go
if exists (select * from dbo.sysfulltextcatalogs where name = 'example_ft_cat')
drop fulltext catalog example_ft_cat;
go
create fulltext catalog example_ft_cat;
create fulltext index on dbo.ft_example ([Word], [Description], [Example])
key index pk_ft_example on example_ft_cat;
go
select *
from dbo.ft_example a
join containstable(ft_example, ([Word], [Description], [Example]), 'bird') b
on a.rowid = b.[key]
Merci Monsieur ... Ensoleillé – hisoka21