简体   繁体   中英

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

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 .

Error:

The object 'vw_LegalCollection' is dependent on column 'LName'. ALTER TABLE ALTER COLUMN LName failed because one or more objects access this column.

Is there anyway to modify the column in SQL table without that error? DO I need to drop the view and recreate it?

Please suggest.

Thanks

Yes, I believe you do. So drop and recreate.

Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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