Last active
March 9, 2021 15:16
-
-
Save Alex-Yates/ba023412c99bbfbd1e3fcb9dc24d681a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Attribution to Ivan Donev | |
-- Details: | |
-- http://www.mssqlinsider.com/2013/09/check-databases-part-replication/ | |
-- Requires SA | |
IF IS_SRVROLEMEMBER ('sysadmin') = 1 | |
print 'Current user''s login is a member of the sysadmin role' | |
ELSE IF IS_SRVROLEMEMBER ('sysadmin') = 0 | |
THROW 50001, 'ERROR: Current user''s login is NOT a member of the sysadmin role.', 1 | |
ELSE IF IS_SRVROLEMEMBER ('sysadmin') IS NULL | |
THROW 50001, 'ERROR: The server role specified is not valid.', 1; | |
SELECT | |
name as [Database name], | |
CASE is_published | |
WHEN 0 THEN 'No' | |
ELSE 'Yes' | |
END AS [Is Published], | |
CASE is_merge_published | |
WHEN 0 THEN 'No' | |
ELSE 'Yes' | |
END AS [Is Merge Published], | |
CASE is_distributor | |
WHEN 0 THEN 'No' | |
ELSE 'Yes' | |
END AS [Is Distributor], | |
CASE is_subscribed | |
WHEN 0 THEN 'No' | |
ELSE 'Yes' | |
END AS [Is Subscribed] | |
FROM sys.databases | |
WHERE database_id > 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment