Sql Server Strored Procedure updating multiple rows that meet the same criteria
Posted on 2007-04-02
I want to pass in a variable to a stored procedure such that it can satisfy multiple records using the IN clause. For instance,
create procedure XXX
update tradedetail set price = @price
where tradeId in @tradeList
with @tradeList = a buffer that contains multiple comma separated trade ids, i.e., (1, 3, 4, 8), etc.
Sql Server doesn't like this syntax. Is there a way to accomplish this?
The reason I am doing this is because multiple trades can contain a reference to the same cusip, etc. But when information in the cusip changes I want to update all trades that have that cusip. The problem is, the tradeDetail table does not have a reference to the cusip as that is contained in the TradeMaster.