This OVERPOWERED Hint Will Break NOLOCK Hints In SQL Server

G4M3R


CREATE TABLE
    dbo.view_me
(
    id int NOT NULL
);
GO 

CREATE VIEW 
    dbo.viewed
AS 
SELECT
    vm.*
FROM dbo.view_me AS vm WITH(READCOMMITTED);
GO 

SELECT
    v.*
FROM dbo.viewed AS v WITH(NOLOCK);
GO

Msg 4138, Level 16, State 1, Line 22

Conflicting locking hints are specified for table “dbo.view_me”. This may be caused by a conflicting hint specified for a view.

Thanks for reading!

Going Further


If this is the kind of SQL Server stuff you love learning about, you’ll love my training. I’m offering a 75% discount to my blog readers if you click from here. I’m also available for consulting if you just don’t have time for that and need to solve performance problems quickly.



2 thoughts on “This OVERPOWERED Hint Will Break NOLOCK Hints In SQL Server

  1. what we need is ReadUNCommittedSnapshotIsolation (TM)
    So anything under a NOLOCK hint or ReadUncommitted uses snapshot isolation instead, I’m not holding my breath for that change from Microsoft though.
    Worked last year with a company whose developers still put NOLOCK on everything, I showed them they could get incorrect results and they just shrugged

Comments are closed.