0

I want to pass a comma delimeted string of PK's (int) into a sql stored proc. The proc would then perform an update statement on the table using a where clause including each of the PK's.

What is the best way to do this?

Roger
  • 2,063
  • 4
  • 32
  • 65
  • 1
    there are a lot of answers about CSV processing using SQL, see [Split Function equivalent in tsql?](http://stackoverflow.com/questions/697519/split-function-equivalent-in-tsql) – sll Apr 06 '12 at 14:05
  • good point.. this one looks promising : http://stackoverflow.com/a/3806825/1132773 – Roger Apr 06 '12 at 14:08

1 Answers1

0

We need more information. For instance if the update uses information from tables (joins) or of the rows are getting updated with the same information then you can use:

Update tableName
set ....
where tableName.id in @strOfIdsPassedIn
Kyra
  • 5,129
  • 5
  • 35
  • 55