question

ZaijiaN avatar image
ZaijiaN asked

Programmatically remove schemabinding

I'm writing a sql script to handle updating a database from v1.0 of an app to v1.1.

I'm modifying a table that a view was created against with schemabinding.

Is there a way (using SQL) to momentarily turn off schemabinding for the view, modify the table, then turn schemabinding back on?

Or am I going to have to drop the view, modify the table, then recreate the view?

sql-server-2005sqlt-sql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Matt Whitfield avatar image
Matt Whitfield answered

It's drop the view (and anything else in the dependency tree that depends on that view) and then re-create it. SSMS behaves in funny ways when doing these things sometimes (for example, helpfully dropping SCHEMABINDING left right and centre) - so tread carefully when making changes from within that particular IDE.

One day I will support this style of operation in my tools, but it's a long way off because I have heaps of other stuff to write first, and I can't think of any alternatives off the top of my head, sorry.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.