I would like to update a table but the problem I have is the following: I have a table with more than 60K primary keys in a column called TerminalID
. This table has like 10 more columns, but I would like to update a column called SerialNumber
, but the problem is that the serial number is not the same for every primary key.
The problem is that the update SQL code below will apply the same serial number to all the terminalID
's I have and not a different to each PK.
Any idea?
Use [testserver]
update [testtable]
set SerialNumber =''
from [testtable]
where [TerminalID] in ( ... )
terminalID Serial Number
463328 215728108
168734 213808561
160879 214621937
451991 215523741
This is the only way I can think now , do it one by one
Update [terminalsetting] SET [SerialNumber] ='766' WHERE [TerminalID] ='63872'
Update [terminalsetting] SET [SerialNumber] ='215728108' WHERE [TerminalID] ='463328'
Update [terminalsetting] SET [SerialNumber] ='213808561' WHERE [TerminalID] ='168734'