Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 modify view

Author  Topic 

jassie
Constraint Violating Yak Guru

332 Posts

Posted - 2012-08-06 : 16:40:33
In a sql server 2008 r2 database, I am going to increase the size of a field in a particular table called main. There is a view that uses the table called main. Thus my question is if I increase the size of one of the columns in a table that is included in a view, do I need to change anything in the view? Basically the column I am changing in the view is displayed in the view. Thus do I need to change anything about this view or will the view automatically pickup the field that is expanded? If I need to change something, can you let me know what I need to change?

chadmat
The Chadinator

1974 Posts

Posted - 2012-08-06 : 16:47:59
The view is just selecting that column? If that is the case, you don't have to change anything in the view. Unless the View was defined with SCHEMABINDING, in which case you won't be able to alter the table.

-Chad
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-08-06 : 16:48:35
If the view was created WITH SCHEMABINDING then you'd have to drop it first then re-create it.

If not then you don't have to do anything, although it would be smart to run sp_refreshview to update the view metadata after the column is altered:
EXEC sp_refreshview 'myView'
Go to Top of Page
   

- Advertisement -