Problem Description:
Use snapshot-based transactional replication, add items, execute Snapshot Agent, error message when last published:
Error messages:
Message:the subscription status of the object could not being changed.
Command text:sp_msactivate_auto_sub
Parameters: @publication = 1
@article =%
@status = initiated
Stack:at Microsoft.SqlServer.Replication.AgentCore.ReMapSqlException (SqlException E, SqlCommand command)
At Microsoft.SqlServer.Replication.AgentCore.ExecuteWithResults (Commandsetupdelegate commandsetupdelegate, Processresultsdelegate processresultsdelegate, Int32 QueryTimeout)
At Microsoft.SqlServer.Replication.Snapshot.TransSnapshotProvider.SetPublisherTranSequenceNumViaAutoSub ( Publicationactivationstate publicationactivationstate, SqlConnection connection)
At Microsoft.SqlServer.Replication.Snapshot.TransSnapshotProvider.ActivateCSSPublicationAndSetTranSequenceNums ( Publicationactivationstate publicationactivationstate, SqlConnection connection)
At Microsoft.SqlServer.Replication.Snapshot.TransSnapshotProvider.ConcurrentPreArticleFilesGenerationTransaction ( SqlConnection connection)
At Microsoft.SqlServer.Replication.RetryableSqlServerTransactionManager.ExecuteTransaction (Boolean Bleavetransactionopen)
At Microsoft.SqlServer.Replication.Snapshot.TransSnapshotProvider.DoConcurrentPreArticleFilesGenerationProcessing ( )
At Microsoft.SqlServer.Replication.Snapshot.TransSnapshotProvider.DoPreArticleFilesGenerationProcessing ()
At Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot ()
At Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun ()
At Microsoft.SqlServer.Replication.AgentCore.Run () (Source:mssqlserver, Error number:14068)
Get help:http://help/14068
Server DB, Level A, State 1, Procedure Sp_msrepl_changesubstatus, line 1386
The subscription status of the object could not being changed. (Source:mssqlserver, Error number:14068)
Get help:http://help/14068
Analysis:
Obviously can be seen, is caused by sp_msrepl_changesubstatus, this stored procedure. But the environment is 2012 the problem is shelved when the stored procedure source code is not found.
Today Google's time to find this process, in 2008 time Source: Http://www.g-productions.nl/index.php?name=sp_MSrepl_changesubstatus
Through analysis, it is not difficult to find, in fact, the error is 2 possible, will throw 14068 error:
1.sp_msget_qualified_name, when querying object_name through object_id.
2.sp_mslockmatchid, when you lock an object.
Then first, or through the above site, find Sp_msget_qualified_name source code, found to be through the object_name (ObjID) If the error is null.
By sp_msrepl_changesubstatus the source code, check up to see if the objid of some of the subscribed objects has expired.
DECLARE @publication_ids TABLE(pubidint )INSERT into @publication_ids(pubid)Values(1 ) SELECTSxav.* into#t fromSysextendedarticlesview Sxav, syspublications sp,@publication_ids PiWHERESp.pubid=Sxav.pubid andSp.pubid= Pi. PubIDSELECT object_name(ObjID), name,dest_table,* from#tWHERE object_name(ObjID) is NULL
Found a artid=468 no object name, the next simple, the above SQL, name, can be based on this name to know what the object, see if there is a database, if not, create a new, Modify the Sysextendedarticlesview if it exists.
But the discovery that Sysextendedarticlesview is an attempt, which consists of 2 table union All, depends on which table the object is in:
SELECT * from WHERE = 468 SELECT * from WHERE = 468
My side of the situation is on the Syschemaarticles table.
Processing:
The process is simple:
1. Update out ObjID:
UPDATE SET ObjID=1799833624WHERE=468
2. In the release, cancel this item.
3. In order to test, you can add a new item to test whether the snapshot is normal.
SQL Server replication Snapshot execution error error code 14068