Tuesday, March 27, 2012

Database Being Replicated

I need to detect whether or not a database is being replicated. I need to do
this in a script and use the results in an IF statement. Is the best way to
do this by checking the value of category in the sysdatabases table?
Something like this …
IF EXISTS (SELECT * FROM sysdatabases WHERE [name] = 'emobile_markp' AND
category = 0)
BEGIN
PRINT 'Not replicating'
END
ELSE
BEGIN
PRINT 'Replicating'
END
Thanks,
Mark
You could do this using databasepropertyex:
select name, databasepropertyex (name,'IsMergePublished') from
master..sysdatabases
select name, databasepropertyex (name,'IsPublished') from
master..sysdatabases
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
|||You could also try
sp_helpreplicationdboption and observe the values of transpublish and
mergepublish
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"mrprice" <mrprice@.discussions.microsoft.com> wrote in message
news:36A25480-B64D-4D67-914C-F85A6D0EFA8A@.microsoft.com...
>I need to detect whether or not a database is being replicated. I need to
>do
> this in a script and use the results in an IF statement. Is the best way
> to
> do this by checking the value of category in the sysdatabases table?
> Something like this .
> IF EXISTS (SELECT * FROM sysdatabases WHERE [name] = 'emobile_markp' AND
> category = 0)
> BEGIN
> PRINT 'Not replicating'
> END
> ELSE
> BEGIN
> PRINT 'Replicating'
> END
> Thanks,
> Mark
|||Select name,category from sysdatabases (For SQL Server 2000)
See if it is replicate by
looking at these values
1 = Published.
2 = Subscribed.
4 = Merge Published.
8 = Merge Subscribed.
Select * from sys.datbases
and look for is_published,is_subscribed etc
thankx
"mrprice" wrote:

> I need to detect whether or not a database is being replicated. I need to do
> this in a script and use the results in an IF statement. Is the best way to
> do this by checking the value of category in the sysdatabases table?
> Something like this …
> IF EXISTS (SELECT * FROM sysdatabases WHERE [name] = 'emobile_markp' AND
> category = 0)
> BEGIN
> PRINT 'Not replicating'
> END
> ELSE
> BEGIN
> PRINT 'Replicating'
> END
> Thanks,
> Mark
sql

No comments:

Post a Comment