View Full Version : for each id run query

07-04-2007, 02:19 PM
Hi guys,

i'm new to asp so this may seem easy to some people.

but i have a variable called kal, which is a comma seperated list of id's, how can i run a query to update all records on an mssql db where the id's are equal to the ones listed in the variable kal.

any help would great.

thanks in advance.

07-04-2007, 02:33 PM
update tablename
set fieldname = value
where id in (1,2,3,4,5,6,7,8)

07-04-2007, 02:37 PM
where you have the comma seperated values could i just simply put my varaible name in there?

07-04-2007, 06:00 PM

strIds = "1,2,45,46"
strSQL = "update tablename set fieldname = value where id in (" & strIds &")"