Friday, May 4, 2012

SET ROWCOUNT




---------------------------
Microsoft SQL Server Management Studio
---------------------------
No row was updated.


The data in row 2 was not committed.
Error Source: Microsoft.SqlServer.Management.DataTools.
Error Message: The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows).


Correct the errors and retry or press ESC to cancel the change(s). 
---------------------------
OK   Help   
---------------------------


To workaround this error without modifying the table structure by adding an identity column, use the "SET ROWCOUNT" command.


SET ROWCOUNT 1

update b set column1 = 1
FROM         Table b
WHERE   column2 = 'ABC'

NOTE: The ROWCOUNT statement setting is used for the entire duration of the connection!

1 comment: