SQL Server - ALTER TABLE ALTER COLUMN giving SET option error

I was doing the same thing the OP - alter the PK from INT to BIGINT on 2 tables. In first table it went smoothly, in second table I got same error as OP:

ALTER TABLE failed because the following SET options have incorrect settings: 'ANSI_WARNINGS'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.

Running SET ANSI_WARNINGS ON or OFF is not helping.

The steps are:

  1. drop indexes
  2. drop PK constraint
  3. drop persisted columns
  4. run ALTER TABLE [table] ALTER COLUMN [id] BIGINT
  5. create persisted columns, indexes, PK constraint back as they were

To get rid of the error, there's one thing I had to do differently in step 1:

  • in first table it was OK to drop just indexes using the changed column, keep other indexes
  • in second table I had to drop all indexes, even those not using the column