I have to run a simply query like select * from table_a where col1 in (val1,val2, ..., valn)
with a very large number of values of the order of tens of thousands. These values are extracted from logs and can be any alphanumeric string e.g. 001034abz10t
There is a limit on the number of values I can copy paste in to a query string in SQL Server Management Studio as a result I have to break the original set of values into smaller sets and run the query with each set.
Is there a way to do it with just one query either in SSMS or from the command line using sqlcmd or any other tool? with sqlcmd is there a limit on the length of a variable that can be passed to a script via the -v parameter. There will be one variable representing all the values val1, val2,...valn
as a single string.
I have to run similar queries on DB2 and Oracle also so any info on doing it interactively or from the command line will be greatly appreciated!