6

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?

1 Answer 1

9

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 ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.