I had a similar problem when I needed to have an IN in my select query, and the number of elements changed at runtime.
I use a parameterized query in the form of a stored procedure and pass a delimited string containing a list of the things I'm looking for. The crew is automatically processed by the system, there is no need to take unusual steps. Itβs better not to limit it to characters that will be found in the text you are looking for (for example, commas). the vertical bar ("|") is likely to work best in many cases.
By the way, make sure that the CRLF in your table is CHAR (13) + CHAR (10), because the opposite path is not \ r \ n, and you will not find it if it is environment. NewLine was part of your search.
This is where the procedure is stored using quick and dirty analysis allowing the use of the table I used:
CREATE PROCEDURE FindBooks ( @list varchar(500) ) AS CREATE TABLE
Simply create your list of book titles as a simple string (containing all the built-in apostrophes, CRLF, etc.) and use a parameterized query. Of course, your saved proc may contain other things besides a delimited list.
Cyberherbalist
source share