The problem statement is weak as no developer will usually be allowed to issue random Update statements on a financial production environment. Also a developer who forgets to include a WHERE clause may make mistake in forming the WHERE clause and still can cause updating wrong set of data. So, you may consider copying the records to an AUDIT table from DELETED set in your trigger for auditing and reconciliation purpose rather than focusing on row_count.
-SB
luciano furlan (1/25/2011)
It is a smart workaround, but it doesn't really solve the problem in an elegant way.I miss a configuration on Sql server that states "Where Clause mandatory". For all tables, for all Sql statements.
I fear every day, that I will forget the where clause eventually and destroy an entire table.
And guess what: Sql doesn't have an Undo button!
But still if you need (and you will need) you can write "Where 1=1", to update/delete every record in a table.
Your workaround treats it like a "missing where".
You can see the difference between an accidentaly forgoten where and one you written on purpose.
I believe this is a huge "security hole" in the Sql language. And yet it stays with us for so many years (and so many tears).
I disagree: what about using transactions?
In general, this trigger affects performance just to prevent programmers errors.
Before any DDL or MDL I use the fantastic "SET IMPLICIT_TRANSACTIONS ON".
and only when I sure of modification I run the COMMIT command.
carlos.ramon.martinez (1/25/2011)
Hello,just to finish undestanding, I would like to know in which cases @@rowcount can be greater than the number of rows. If anybody could explain I would appreciate.
Kind regards
Rowcount can be greater than the number of rows listed in the statistics if the statistics have not yet been updated for recently added rows.
[font="Arial"]_______________________________________________________
Change is inevitable... Except from a vending machine.[/font]
Viewing 15 posts - 1 through 15 (of 95 total)
You must be logged in to reply to this topic. Login to reply