dragon.warrior.nyc
dragon.warrior.nyc

Reputation: 71

Is it possible to alter view with nolock in SQL Server?

Is it permitted to alter view with nolock? If so, how should I use it if I want to?

ALTER VIEW dbo.xx_view 
AS
    SELECT * 
    FROM dbo.yy

My current issue is that I have to wait for others finish using dbo.xx_view, then the view can be altered. Is there a way that I can alter the view forcibly, even when others are making queries on it.

Upvotes: 0

Views: 2206

Answers (1)

Nisarg Shah
Nisarg Shah

Reputation: 14561

You can specify it just like any other select statement:

ALTER VIEW dbo.xx_view AS
SELECT * FROM dbo.yy WITH (NOLOCK)

Or, you could provide the NOLOCK hint while querying on the view as suggested here:

 SELECT * FROM dbo.xx_view WITH (NOLOCK)

In the latter case, your query inside the view need not provide the NOLOCK hint.

Upvotes: 2

Related Questions