Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

ANSI_WARNINGS off, deny permissions = transaction killed - Why?

$
0
0

When ANSI_WARNINGS are ON and an insert fails due to permissions being denied, a transaction continues.

When ANSI_WARNINGS are OFF and an insert fails due to permissions being denied, a transaction is aborted.

In all my reading of the ANSI_WARNINGS documentation, I don't see anything that describes this behavior. Could someone please explain this?

Code to reproduce:

--------do this as sa--------- CREATE TABLE Junk( Name varchar(12) ) INSERT INTO Junk(Name) VALUES ('original') DENY INSERT ON Junk to dbUser --------------------------------- ---now do this as dbUser (update is not attempted)--- SET ANSI_WARNINGS OFF BEGIN TRAN INSERT INTO Junk(Name) VALUES ('new') update Junk SET Name = 'updated' where Name = 'original'

COMMIT TRAN -------------------------------- ---again as dbUser, do this (update is done)---- SET ANSI_WARNINGS ON BEGIN TRAN INSERT INTO Junk(Name) VALUES ('new') update Junk SET Name = 'updated' where Name = 'original'

COMMIT TRAN -----------------------------




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>