"Could not find the distributor or the distribution database for the local server"

I am unable to set up a publisher for merge replication on an SQLServer 2005 database.
I am using the replication wizard to add a publisher and get the following error message :-
"Could not find the distributor or the distribution database for the local server"
The distributor database is on the same server and is registered.
The server name is not NULL.
I have spent a long time on this problem but o no avail ?
Any suggestions please ?
Roger AlcindorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In SQL Server Management Studio, Right click on 'Replication' and select 'Configure Distributor'

Roger AlcindorAuthor Commented:
There is no 'Configure Distributor' option, there is a 'Distributor Properties' however, is that what you mean ?
If so then I have already looked at the distrubutor properties and it shows the distributor database and I have already checked that area and set sa and password.

Any other suggestions
In that case, select 'Disable...' and repeat the setup. That should kick things into life.

Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

Roger AlcindorAuthor Commented:
I had already tried that and have tried it again but in both cases I get the following error messages:-

"SQL Server could not disable publishing and distribution on 'server name'

Additional Information :
An Exception Occurred while executing a Transact SQL statement or batch

The distributor has not been installed correctly. Could not disable database for publishing.
Changed database context to 'master'. [Microsoft SQL server error 20029]
Roger AlcindorAuthor Commented:
I have now uninstalled SQL server 2005 and re-installed it from scratch.
I still have the same problem.
I have been through the configure distributor opton from right-clicking on Replication and it completed without error indicating success.
I cannot however disable publishing an distribution and get the same error message as last mentioned.
Any ideas please ??
Give me a moment, gonna have a play on a testbox.

First off, try this:

EXEC sp_get_distributor - What does it come back with? If 'Distribution Server' is NULL, then create a new database called 'distribution' then run the below statement:

EXEC sp_adddistributiondb 'Distribution'

I'm guessing this will fail with the below message:

"Replication components are not installed on this server. Run SQL Server Setup again and select the option to install replication."

Run SQL Setup and try the suggested.

Roger AlcindorAuthor Commented:
I have re-installed SQL Server again and checked that the replication option was selected
I have configured distribution with the default database name of distribution and success was indicated.

When I run exec sp_get-distributor I get the name of the server plus three fields indicating distribution db installed, is distribution publisher, has remote distribution publisher; values of 1,1 and 0 respectively.

when I run exec sp_adddistributiondb 'distribution' ,I get an error message asfollows:-
"Could not add the distribution database 'distribution'. This distribution database already exists.

I still get the same messages if I try to add a publication or disable publishing and distribution as described previously.

I am getting desperate ?
The 2nd error I would have expected given the distributor is setup.

Have you enabled the DB for replication?

exec sp_replicationdboption 'DBName','publish','true'

Roger AlcindorAuthor Commented:
I ran exec sp_replicationdboption 'WQ01','publish','true' and got an error as follows:-

Msg 20028, Level 16, State 1, Procedure sp_MSpublishdb, Line 55
The Distributor has not been installed correctly. Could not enable database for publishing.
The replication option 'publish' of database 'WQ01' has been set to false.

Just to check the basics, What version of SQL Server are you using, what SP level ?

e.g. 2005 Enterprise 9.0.3257


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roger AlcindorAuthor Commented:
SQL Server 2005 Standard Edition 9.00.3042.00
Windows N.T. 5.00.2195   (Windows 2000 server) SP4

Roger AlcindorAuthor Commented:
I have resolved the problem!
I believe that the root cause was due to having imported a database from another server (attach to a copy of the MDF file) whereby the database had been published on another server.
I fixed the problem by using  exec sp_removedbreplication @dbname =  'databasename'
then adding a distributor and everything worked as expected except that the "Disable publishing and Distribution " doesn't work but I don't need to do that.
Thanks for you help,

Excellent. Glad you got this one resolved!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.