# Database Discussions > MS SQL Server 7/MS SQL Server 2000 >  Msg 14013, not enabled for publication.....

## DLu

Hi, 
I tried to run the following script from SQL2005 server A (publisher) from Database 'TestDB' to SQL2005 server B
(subscriber) database 'TestDB'
-------------------------------------------
exec sp_addsubscription @publication = N'publish_TestDB_FromCA', @subscriber = N'subscriberTest', @destination_db = N'TestDB', @subscription_type = N'Push',   @sync_type = N'automatic',  @article = N'all', 
@update_mode = N'read only',  @subscriber_type = 0

with following error:

Msg 14013, Level 16, State 1, Procedure sp_MSrepl_addsubscription, Line 252
This database is not enabled for publication.

Any idea?
Thanks
David

----------


## DLu

oops, I point to the wrong DB. the subscription job is now generated from the sql/w. but not show up from the subscription side yet. 

After re-initialization, not show yet....

----------


## skhanal

What kind of replication did you set?. It seems it is push subscription type, so there will be no job in subscriber, all the jobs will be in publisher.

----------


## DLu

Hi Skhanal:
you are right, the push jobs are created on publisher side.
from publisher db, I ran both script of 
exec sp_addsubscription @publication  'publish_A',,,, and  
exec sp_addpushsubscription_agent @publication = N'publish_A' 
with job created on publisher, but the corresponding subscription replication was not showing up at the subscriber server B. I have met with this kind issue before. The solution is reinitilization. But for certain reason, the reinitialization did not work.
thanks
David

----------


## skhanal

Is this merge replication?, otherwise there will not be any jobs in subscriber for push subscription.

----------


## DLu

Hi Skhanal:

It is push repl. And the jobs are created in publisher server.
However, the corresponding replication did not show up in the subscriber server replication/local subscription folder. The target db has been backuped from A and copied to the server B. Both A and B are SQL2005, and both sql server service and sql agent service are using the same domain\userTest login.

thanks
David

----------


## rmiao

Is it transactional or merge replication? Tried set replication in SSMS?

----------


## DLu

It is transactional push repl. I have tried to add subscription with manual process. From publisher replication monitor, I could see that subscription watch list is fine. But in "Warnings and Agent" tab, job "Snapshot Agent" with error:

Executed as user: domainName\userTest. The replication agent encountered a failure. See the previous job step history message or Replication Monitor for more information.  The step failed.

The log reader agent is running fine. But I checked login domainName\userTest is running fine in both server A and B on sql server service and sql agent service. Why it is fail in the snapshot agent stage?

thanks
-D

----------


## DLu

Message
Error: 14151, Severity: 18, State: 1.

Agent shutdown. For more information, see the SQL Server Agent job history for job 'publish_TestDB_FromA'.

found above 2 error messages from publisher sql log.
What caused the "Agent shutdown"?

----------


## DLu

The agent error comes from Snapshot Agent.

----------


## rmiao

Any error in sql agent error log? Try set replication in SSMS to see if have same problem, you may miss some steps in setup.

----------


## DLu

Hi:
I dropped publication and subscriptions and from SQL Console created publication via clicking: all 4 steps successful including start snapshort agent.
But when I check the view snapshot agent status: following error:

Executed as user: domain\userTest. The replication agent encountered a failure. See the previous job step history message or Replication Monitor for more information.  The step failed.

from sql agent error log:
[298] SQLServer Error: 14262, The specified @job_id ('E564EAD0-A7A8-47DF-AE21-C5971BEE6A6E') does not exist. 
[SQLSTATE 42000]
[000] Unable to retrieve steps for job publication_A-To-8
[180] Job publication_A-B was deleted while it was executing: the outcome was Failed.

SSMS or scription creation with the same error. How could aovid the snapshot agent failure?

thanks
-D

----------


## rmiao

What's your sql2k5 edition and sp level? Did you get correct sql instance name with 'select @@servername' on both servers? How did you set credentials when setup replication?

----------


## DLu

publish server version
Microsoft SQL Server 2005 - 9.00.3054.00 (X64) 
Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)

subscriber server version
Microsoft SQL Server 2005 - 9.00.1399.06 (X64) 
Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)

both servername are correct with on '\' instance attached.

p.s. When I create the new subscription under publication, all steps were created correctly including "start snapshot agent", then I immediately swithed to look at the 'view snapshot status" and found it was running! but 5 seconds later, it was faile with the "Executed as user: domainName\testUser. The replication agent encountered a failure. See the previous job step history message or Replication Monitor for more information.  The step failed."

replication security set is with same domainName\userName which is used in both publish/subscriber, both sql server service and sql agent service. communication is via sa with same password on both server.

thanks
-D

----------


## DLu

Server		A
Job Name		publication_A
Step Name	Detect nonlogged agent shutdown.
Duration		00:00:00
Sql Severity	18
Sql Message ID	14151

Message
Executed as user: domainName\testUser. Agent shutdown. For more information, see the SQL Server Agent job history for job 'publication_A'. [SQLSTATE 01000] (Message 20557)  Replication-Replication Snapshot Subsystem: agent publication_A failed. Executed as user: domainName\testUser. The replication agent encountered a failure. See the previous job step history message or Replication Monitor for more information.  The step failed. [SQLSTATE 42000] (Error 14151).  The step failed.

----------


## rmiao

Possible to get subscriber to version 3050?

----------


## DLu

After re-install SQL2005 on server A, publication set up successful including snapshot agent generated 18 articles, and all 5 subscription with no-error.

----------


## DLu

Hi Rimao:

I have also upgraded all subscriber to 3050, but server A still has the same snapshot agent error, till it was re-installed.
p.s. I also tried reverse way: to make one subscriber server B as the publisher, and server A as the subscriber with 0 error.

thanks
-D

----------

