Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I'm trying to change the size of a column in SQL server using:

ALTER TABLE [dbo].[Address]

ALTER COLUMN [Addr1] [nvarchar](80) NULL

where the length of Addr1 was originally 40.

It failed, raising this error:

The object 'Address_e' is dependent on column 'Addr1'.

ALTER TABLE ALTER COLUMN Addr1 failed because one or more objects access 

this column.

I've tried to read up on it and it seems that because some views are referencing this column and it seems that SQL Server is actually trying to drop the column that raised the error.

Address_e is a view created by the previous DB Administrator.

Is there any other way I can change the size of the column?

1 Answer

0 votes
by (40.7k points)

Use the below code:

ALTER TABLE [table_name] ALTER COLUMN [column_name] varchar(150)

Related questions

0 votes
1 answer
asked Jan 5, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...