Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. USE DatabaseName
  2. GO
  3.  
  4. CREATE TRIGGER [Table].[uPreventUpdateOops]
  5. ON [Table].[Column]
  6. FOR UPDATE AS
  7. BEGIN
  8. DECLARE @Count int
  9. SET @Count = @@ROWCOUNT;
  10.  
  11. IF @Count >= (SELECT SUM(row_count)
  12. FROM sys.dm_db_partition_stats
  13. WHERE OBJECT_ID = OBJECT_ID('Table.Column' )
  14. AND index_id = 1)
  15. BEGIN
  16. RAISERROR('Cannot update all rows',16,1)
  17. ROLLBACK TRANSACTION
  18. RETURN;
  19. END
  20. END
  21. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement