This is very easy to test. Firstly, in a sandbox environment, run the following:
CREATE TABLE dbo.MyTable (ID int);
GO
CREATE VIEW dbo.MyView AS
SELECT ID
FROM dbo.MyTable WITH (NOLOCK);
GO
CREATE VIEW dbo.MyView2 AS
SELECT ID
FROM dbo.MyTable;
GO
BEGIN TRANSACTION Test;
INSERT INTO dbo.MyTable
VALUES(1);
Notice I don't COMMIT
the transaction. Now in a new window, run SELECT * FROM dbo.MyView;
. Notice it returns results. If you also try SELECT * FROM dbo.MyView2 WITH (NOLOCK);
You'll also get results. Try SELECT * FROM dbo.MyView2;
, however, and the query will "hang".
You can then "clean up" by returning to your original query window and running the following:
COMMIT;
GO
DROP VIEW dbo.MyView2;
DROP VIEW dbo.MyView;
DROP TABLE dbo.MyTable;
Of course, the real question is, do you need NOLOCK
, but that isn't what this question is about.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…