开发者

How to determine if the SQL Server supports replication

I have a UI that needs certain portions to be disabled if the SQL Server it's connecting to does not support replication and which types of replication it supports (snapshot, merge, transactional). I looked through the doc for the SERVERPROPERTY function, but didn't see anything that looked like it was what I needed. Any suggestions?

Note - It would be preferable t开发者_JS百科o not have to resort to switching on the Edition.


Even if a SQL Server instance is capable of doing replication, it is still not certain whether it is configured, and whether the administrator has it active.

For all these uncertainties, the most useful application solution is to define a flag in one of your application's tables indicating whether the replication-related logic should be enabled. This also makes system testing simple.


You can try to set up replication using the objects of the Microsoft.SqlServer.Replication namespace in a Try Catch block. If it bombs, then disable the replication portion of your app.


So it looks like there is no easy way to determine if replication is supported, however, it is possible to determine if the database is being replicated:

SELECT name, CASE WHEN is_published = 1 OR is_merge_published = 1 OR is_distributor = 1 THEN 1 ELSE 0 END AS uses_replication FROM sys.databases

That's about as close as I can get I think.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜