Hvis du har multiple patterns
for at søge er det bedre at oprette en derived table
eller temporary table
for at gemme patterns
DECLARE @patterns TABLE (
pattern VARCHAR(20)
);
INSERT INTO @patterns VALUES ('%$%'), ('%[%]%'), ('%ac cd%');
SELECT a.* FROM table_name a JOIN @patterns p ON (a.Description LIKE p.pattern);
Hvis du har flere kolonner at sammenligne, skal du blot tilføje udtryk i ON
klausul
SELECT a.* FROM table_name a JOIN @patterns p ON (a.Description LIKE p.pattern)
OR (a.Column2 like p.pattern);
Opdateret:Bruger Vis
CREATE VIEW PatternSearch
AS
WITH Patterns (Patterns)
AS
(
Select '%Tool%'
union all
Select '%Sale%'
union all
Select '%ac cd%'
)
SELECT a.* FROM table_name a JOIN Patterns p ON (a.Description LIKE p.pattern)
GO
Ikke testet, men du kan gøre sådan her