SQL Server – Can a View with Schemabinding be Altered if Binding Requirements are Met

lockingschemasql-server-2008-r2view

In SQL Server 2008, I have views WITH SCHEMABINDING and I need to alter one.

I am changing a column while not changing its alias so consumers will be unaffected.

If I were to drop all my other views that depend on this I would be able to recreate them again, so SCHEMABINDING is still valid.

Can I temporarily disable the schema lock on this view in order to ALTER it?

Or must I drop the dependent views and recreate them once it's changed?

Best Answer

You don't need to drop the dependent views, but you do need to alter them to (temporarily) not be schemabinding. If any of them are indexed, this means you will need to re-create the indexes.

SQL Server doesn't have some weighting system for schemabinding: you can't change the object. Period.

ALTER VIEW dbo.view_name
--Remove this WITH SCHEMABINDING
AS
  SELECT ...