Reputation: 371
I want to build a query like this:
SELECT * FROM T1 WHERE Charindex(ANY(SELECT City FROM Cities),T1ADDRESS)>0
As i understand, the ANY
operator cannot stay as SQL functions argument. So, what is the alternative?
Suppose I want to write a UDF that returns 1 or 0 dependent on one input argument Address. How do I do this without for
loop operator and without accessing to SELECT City FROM Cities
array by index, as it can be done easily in the procedural languages?
Upvotes: 0
Views: 110
Reputation: 3850
Have you tried a JOIN
?
SELECT *
FROM T1
INNER JOIN CITIES
ON T1ADDRESS LIKE '%' + City + '%'
Not sure about performance however...
Upvotes: 1
Reputation: 17354
You might want to do something like this?
SELECT * FROM T1 WHERE Charindex in (SELECT '%'+City+'%' FROM Cities)
which address the ANY problem but not everything you asked for.
Upvotes: 0
Reputation: 35716
How about,
SELECT
*
FROM
T1
WHERE
EXISTS
(
SELECT City FROM Cities WHERE T1.T1ADDRESS LIKE '%' + City + '%'
)
Upvotes: 0