PRB: Error 5074 occurs when you try to drop a column from a published table (816755)
The information in this article applies to:
- Microsoft SQL Server 2000 (all editions)
SYMPTOMSWhen you drop a column from a transactional or a merge
replication published table, SQL Server 2000 does not drop the column, and you
may receive the following error message: Server: Msg
5074, Level 16, State 1, Line 1 The object '<constraint name> ' is
dependent on column ' <column name> '. Server: Msg 4922, Level 16,
State 1, Line 1 ALTER TABLE DROP COLUMN <Column name> failed because
one or more objects access this column.
CAUSEThere is a constraint on the column that you tried to
drop.WORKAROUNDTo work around the problem, remove all the constraints that
are defined on the column that you want to drop. For example: - Make a note of all the constraints that are defined on the
column that you want to drop.
Note When you try to drop the column (that has a constraint) from a
published table by using the sp_repldropcolumn stored procedure, the list of objects dependent on the column are
displayed in the error message. These are the constraints that are defined on
the column. - At the publisher, create a script to remove all the
constraints that are defined on the column you want to drop from the published
table.
For example, to create a script to drop a constraint, follow
these steps:
- Open Notepad.
- Paste the following Transact-SQL command:
alter table <PublishedTableName> drop constraint <ConstraintName> go
Note Replace the PublishedTableName and ConstraintName with the name of the published table and the constraint name
respectively. - Save the file as DropConstraint.sql.
- At the publisher, run the DropConstraint.sql script by using the osql command prompt utility.
To do so, follow these steps:
- Open a command prompt.
- Locate the <Installation drive>:\Program
Files\Microsoft SQL Server\80\Tools\Binn folder.
- At the command prompt, type the following osql command:
osql -S <serverName> -U
<userName> -P <password> -i <path Of DropConstraint.sql> -d
<publicationDatabase>
- If the replication type is merge replication, you must drop
the constraints at the subscriber. To do so, run the following Transact-SQL
command in SQL Query Analyzer at the publisher:
use <PublicationDatabase> go sp_addscriptexec @publication = <PublicationDatabase>, @scriptfile = <path of DropConstraint.sql> go
- At the publisher, drop the column from the published table:
use <PublicationDatabase> go exec sp_repldropcolumn @source_object = <PublishedTableName>, @column = <columnName> go
REFERENCESFor additional information about schema changes, visit the
following Microsoft Web site: http://msdn.microsoft.com/library/en-us/replsql/replimpl_22pf.asp
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
293464
FIX: Merge replication does not log conflicts after successively adding and dropping columns
319691 FIX: Merge subscriptions may reinitialize unexpectedly if incremental schema change fails
Modification Type: | Major | Last Reviewed: | 12/3/2004 |
---|
Keywords: | kbTSQL kberrmsg kbprb KB816755 kbAudDeveloper |
---|
|