I have a stored procedure that has this line:
SET @SQL = 'SELECT path,title,tags
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY file_number) AS Row, *
FROM files) AS tbl
WHERE file_number IN (SELECT tag_file_number
FROM tags
WHERE tag LIKE ' + @Conditions + '), Row >= '
+ CONVERT(varchar(9), @StartIdx) + ' AND
Row <= ' + CONVERT(varchar(9), @EndIdx)
I get an error when I pass ‘bus’ as a parameter value. My objective is to pass a piece of SQL query and substitute it in the place of @conditions.
I may also pass ‘%bu% or tag Like %time% or tag Like %bus time%’ I think this is not hard to do but I simply can’t figure it out. It’s a very specific problem, therefore I can’t even google it up. Please help me. Let me know if you need any more information.
You are missing the quotes, try it like this:
Now what’s happening is
where tag like busand it must bewhere tag like "bus".