SQLTeam.com | Weblogs | Forums

Store Procedure for Multiple Updates


#1

I want to create a stored procedure to execute multiple updates - around 50 - 100. I don't know the data or the ID before runtime. Do I pass in a list of id's and a list of values? If so how? Or do I iterate in code to call the update statement 100 times? like:

'execute update someValue someKey'

or just pass in lists
'execute update list(someValue) list(someKey)
or
execute update list(someKey, someValue)

UPDATE Table SET (column1 = 'someValue') WHERE column2 = 'someKey')
UPDATE Table SET (column1 = 'someValue') WHERE column2 = 'someKey')
UPDATE Table SET (column1 = 'someValue') WHERE column2 = 'someKey')

#2

Pass in a table of keys and values. You can use a user-defined-data-type table with a table variable OR a temp table OR even a permanent table to pass the data in.


#3

ok thanks