Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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.4k points)

Use the below code:

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

Related questions

0 votes
1 answer
asked Jan 5 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94k users

Browse Categories