Quantcast
Channel: SQL Steve » SQL Server 2008
Viewing all articles
Browse latest Browse all 20

SQL Server–Database Configuration Report

$
0
0

When coming in to a new environment, it’s a good idea to get a baseline of all of the databases on each of the systems in the environment.  The script below will generate a report of all of the databases on a given SQL Server instance.  Looking through the results you can quickly identify differences and anomalies between databases.

use master
GO
 
SELECT
    D.name AS DatabaseName,
    CONVERT(BIT,
    CASE WHEN source_database_id IS NULL THEN 0 ELSE 1 END) AS IsSnapshot,
    SP.name AS DatabaseOwner,
    D.create_date AS DatabaseCreateDate,
    D.compatibility_level AS DatabaseCompatibilityLevel,
    D.collation_name AS DatabaseCollation,
    D.user_access_desc AS UserAccess,
    CASE WHEN is_read_only = 1 THEN ‘READ_ONLY’ ELSE ‘READ_WRITE’ END AS ReadWriteAccess,
    D.is_auto_close_on AS AutoCloseEnabled,
    D.is_auto_shrink_on AS AutoShrinkEnabled,
    D.state_desc AS State,
    D.is_in_standby AS InStandby,
    D.is_cleanly_shutdown AS IsCleanlyShutdown,
    D.snapshot_isolation_state_desc AS SnapshotIsolation,
    D.is_read_committed_snapshot_on AS IsRCSIEnabled,
    D.recovery_model_desc AS RecoveryModel,
    D.page_verify_option_desc AS PageVerificationModel,
    D.is_auto_create_stats_on AS AutoCreateStats,
    D.is_auto_update_stats_on AS AutoUpdateStats,
    D.is_auto_update_stats_async_on AS AutoUpdateStatsAsync,
    D.is_ansi_null_default_on AS AnsiNullDefault,
    D.is_ansi_nulls_on AS AnsiNulls,
    D.is_ansi_padding_on AS AnsiPadding,
    D.is_ansi_warnings_on AS AnsiWarnings,
    D.is_arithabort_on AS ArithAbort,
    D.is_concat_null_yields_null_on AS ConcatNullYieldsNull,
    D.is_numeric_roundabort_on AS NumericRoundAbort,
    D.is_quoted_identifier_on AS QuotedIdentifier,
    D.is_recursive_triggers_on AS RecursiveTriggers,
    D.is_cursor_close_on_commit_on AS CursorCloseOnCommit,
    D.is_local_cursor_default AS LocalCursorDefault,
    D.is_fulltext_enabled AS FullTextEnabled,
    D.is_trustworthy_on AS Trustworthy,
    D.is_db_chaining_on AS DbChaining,
    D.is_parameterization_forced AS ForcedParameterization,
    D.is_master_key_encrypted_by_server AS MasterKeyEncryptedByServer,
    D.is_published AS Published,
    D.is_subscribed AS Subscribed,
    D.is_merge_published AS MergePublished,
    D.is_distributor AS Distributor,
    D.is_sync_with_backup AS ReplicationSyncWithBackup,
    D.is_broker_enabled AS BrokerEnabled,
    D.is_date_correlation_on AS DateCorrelationEnabled,
    D.is_cdc_enabled AS CdcEnabled,
    D.is_encrypted AS Encrypted,
    D.is_honor_broker_priority_on AS HonorBrokerPriority
FROM
    sys.databases AS D
    INNER JOIN
    sys.server_principals AS SP
    ON
    D.owner_sid = SP.sid
ORDER BY
    DatabaseName
GO

Filed under: SQL Server, SQL Server 2008, SQL Server 2012, SQL Server 2014 Tagged: SQL Server, sys.databases, sys.server_principals

Viewing all articles
Browse latest Browse all 20

Latest Images

Trending Articles



Latest Images