We have scenario:
- SQL Server 2008
- we have replication on the db
- we have simple sproc that performs ALTER of one of the table (add new column)
- isolation level is default (READ COMMITTED)
Stored procedure fails with error:
You can only specify the READPAST lock in the READ COMMITTED or REPEATABLE READ isolation levels
Questions:
- What causes the problem?
- How to fix that?
UPDATE:
I believe this is very common problem so I’m wonder why there is no good explanations why replication causes this issue
You cant only specify READPAST when reading from committed data.
Reason is because readpast ignores locked rows, so when you use it, you are pretty much saying to sql server, give me everything that has not been touched by any other transaction. Example from BOL:
It doesnt make much sense saying that on a read uncommitted isolation level, which by default, brings back uncommitted values. Its kinda requesting two opposite things.