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 2005 Forums
 Transact-SQL (2005)
 Problem altering column length

Author  Topic 

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2008-02-18 : 07:10:04
Hi all,

I'm trynig to alter the length of a column in a table like so :

alter table dbo.Domicile alter column PostCounty varchar(30)


Simple right? BUT I get the following error :

Msg 5074, Level 16, State 1, Line 1
The object 'vw_LiveNameAndAddress' is dependent on column 'PostCounty'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE ALTER COLUMN PostCounty failed because one or more objects access this column.


I checked the view definition and it has the with schemabinding clause so I don't understand what's all the fuss about.

Please advise.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-18 : 07:17:54
If VIEW is created with SCHEMABINDING clause, you won't be able to drop or alter underlying objects unless you remove SCHEMABINDING clause from the view.


Books online says this about SCHEMABINDING clause:

quote:
SCHEMABINDING

Binds the view to the schema. When SCHEMABINDING is specified, the select_statement must include the two-part names (owner.object) of tables, views, or user-defined functions referenced.

Views or tables participating in a view created with the schema binding clause cannot be dropped unless that view is dropped or changed so that it no longer has schema binding. Otherwise, SQL Server raises an error. In addition, ALTER TABLE statements on tables that participate in views having schema binding will fail if these statements affect the view definition.


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2008-02-18 : 07:19:29
Thanks harsh. That answers my question.
Go to Top of Page
   

- Advertisement -