简体   繁体   English

更改用于视图的sql表中的列

[英]Alter a column in sql table which is used a view

I would like to alter a column to increase the size of it from [varchar](50) to [varchar](100) . 我想更改一列以将其大小从[varchar](50)增加到[varchar](100)

ALTER TABLE [dbo].[TestLegal]
    ALTER COLUMN [LName] [varchar](150) NOT NULL; 

The above is query is failing because the LNAME column is being used in a view vw_LegalCollection . 上面的查询失败,因为视图vw_LegalCollection使用了LNAME列。

Error: 错误:

The object 'vw_LegalCollection' is dependent on column 'LName'. 对象“ vw_LegalCollection”取决于列“ LName”。 ALTER TABLE ALTER COLUMN LName failed because one or more objects access this column. ALTER TABLE ALTER COLUMN LName失败,因为一个或多个对象访问此列。

Is there anyway to modify the column in SQL table without that error? 反正有没有修改SQL表中的列而没有该错误? DO I need to drop the view and recreate it? 我需要删除视图并重新创建它吗?

Please suggest. 请提出建议。

Thanks 谢谢

Yes, I believe you do. 是的,我相信你会的。 So drop and recreate. 因此,删除并重新创建。

Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM