In my software I have a process which runs the database updates that I need to apply to patch up to our latest version. In my latest script, I want to add a column to a table that has a publication for replication setup. When I create my alter script to add the columns I get a message saying the following:
You can only specify the READPAST lock in the READ COMMITTED or REPEATABLE READ isolation levels.
Any ideas what the easiest way to get round this issue is? Do I have to script a remove of the publication and then re-add it afterward!?
We had this issue this week while using scripts generated by SQL Compare to synch our production and dev environments. The issue is caused by the script from SQL Compare (or whatever you are using) starting a transaction with a higher isolation level than READ COMMITTED or REPEATABLE READ.
When you run the part of the script hat has the ALTER TABLE to add the column, that initiates a call to the SQL replication code that propogates the ALTER TABLE command to the subscribers. That code can’t execute inside of the larger transaction with the higher isolation level.
The solution we used was to script out the replication. Drop the replication on that table. Apply the synch script. Then recreate the replication.
The alternative would be to edit the synch script to change the isolation level of the transaction or remove it altogether. That was not something we wanted to do so we went with the previously mentioned solution.