I have a table that has a whitelist of all valid domains. The column in question is called "URL"
URL column is VARCHAR(60) and @url is a .Net string primitive.
I want a SQL statement that returns "1" if the SQL parameter provided starts with the whitelisted URLs I have stored on my table. This is what I have:
SELECT 1
FROM [TABLE]
WHERE @url LIKE (URL || '%')
But it doesn't work and gives the following error:
A LIKE predicate or POSSTR scalar function is not valid because the first operand is not a string expression or the second operand is not a string.
An example of what I'd like to happen is when given the parameter value of HTTP://WWW.GOOGLE.COM/ANYTHING/AFTER/THIS and there is a row on my table that looks like HTTP://WWW.GOOGLE.COM it will return "1", but if there is not a row that starts with the domain then return null.
Example table values:
HTTP://WWW.GOOGLE.COM
HTTPS://WWW.ANOTHERWEBSITE.GOV
HTTP://WWW.DOMAIN.CORP
HTTP://MY.WEBSITE.COM
HTTPS://STUFF/SUBDOMAIN/
HTTP://BUSINESS.JUNK.CORP/