Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Big parameter list for SQL query

I have a big list of int parameters for a SQL query:

update mytable set col='xyz'
where id in (/* thousands of ints */)

My problem is that in SQL Server 2000 there are a limit for parameters. I could run this query on an SQL Server 2008 too.

What is the better way to do this.

Edit:

The list of Ids come from a C# program. Not from another table.

like image 997
Floyd Avatar asked Oct 25 '10 16:10

Floyd


1 Answers

You can insert the integers into a temp table, and then query like this:

update mytable m set col='xyz' 
where exists (select * from #MyTempTable where id = m.id)
like image 70
D'Arcy Rittich Avatar answered Sep 30 '22 02:09

D'Arcy Rittich