question

JoelSL avatar image
JoelSL asked

Alter large synchronized database table column having dependent columns

Hi,
i am a dba with a NYC government agency (legal limitations prevent me from disclosing which).

We are attempting to alter a large, synchronized database's table's column with dependent objects. When we tried the following alter command:

USE [dbadmin]

GO

alter table [dbo].[sampleTable] alter column [sampleColumn] varchar(250)

GO

we got the following:

Msg 5074, Level 16, State 1, Line 4

The object 'dependentObject' is dependent on column 'sampleColumn'.

Msg 4922, Level 16, State 9, Line 4

ALTER TABLE ALTER COLUMN sampleColumn failed because one or more objects access this column.


Completion time: 2021-05-13T13:51:56.2234608-04:00


When we tried the command with:

alter table [dbo].[sampleTable] alter column [sampleColumn] varchar(250)

WITH (ONLINE=ON)

we got:

Msg 319, Level 15, State 1, Line 5

Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.


Completion time: 2021-05-13T14:20:03.4872035-04:00


Can anyone help/advise as to what my next steps might be?

alter-tabledatabase sizedependencysynchronisation
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
anthony.green avatar image
anthony.green answered

Your going to have to work this back and find all the dependencies, it has given you the first one "dependentObject" you will have to remove that dependency and re-try the alter, then recreate the dependency, rinse and repeat until you can make the change you need.


10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.