SQL SERVER Multiple LIKE Statements::
WITH CTE AS
(
SELECT VALUE
FROM (
VALUES ('B79'), ('BB1'), ('BB10'), ('BB11'), ('BB12'), ('BB18'), ('BB2'), ('BB3'), ('BB4'), ('BB5'), ('BB6'), ('BB8'), ('BB9'), ('BB94'), ('BD1'), ('BD10'), ('BD11'), ('BD12'), ('BD13'), ('BD14'),
('BD15'), ('BD16'), ('BD17'), ('BD18'), ('BD19'), ('BD2'), ('BD20'), ('BD21'), ('BD22'), ('BD3'), ('BD4'), ('BD5'), ('BD6')
) V(VALUE)
)
SELECT *
FROM tbl_ClientFile T
WHERE EXISTS ( SELECT TOP 1 1 FROM CTE WHERE T.CLNTPOST1 LIKE CTE.VALUE + '%')
OWN Exercise ::
WITH CTE AS
(
SELECT VALUE FROM (VALUES ('Generator'),('REB')) V(VALUE))
SELECT date,MCName
FROM TBL_UtilityGeneratorBoilerLogBook T
WHERE CAST(CONVERT(VARCHAR, date, 106) AS DATETIME) between '2019-12-01 00:00:00.000' and '2019-12-16 00:00:00.000' AND
EXISTS ( SELECT * FROM CTE WHERE T.MCName LIKE '%'+ CTE.VALUE + '%' )
No comments:
Post a Comment
I am Safiqul Islam Tuhin