DocumentID = "123" TransactionIDs = "1,2,3,4,5" SQLEXEC("myStoredProc " + m.DocumentID + ", " + m.TransactionIDs)The stored procedure:
ALTER procedure [dbo].[uspAssignTransactions] @DepositVoucherID int = null, @TransactionIDs varchar(4000) = null as select ID into #IDs2Assign from CaseTransactions where charindex(',' + ltrim(rtrim(cast(ID as varchar(10)))) + ',', @TransactionIDs) > 0 and DepositVoucherID is null and ClearedForDeposit = 1 update CaseTransactions set DepositVoucherID = @DepositVoucherID where ID in (select ID from #IDs2Assign)Now, comes the complication. They have multiple branches or locations each with its own database but they want to merge the databases, hence we'll end up with multiple transactions with the same ID. They do have a location code for each branch so each transaction can be identified by the location code and transaction ID.