脚本输出服务器属性和数据库属性

时间:2017-08-16 09:41:06

标签: sql-server tsql sql-server-2014

MSSQL 2014

如果可能,有人可以提供tsql从服务器属性和数据库属性的页面中提取设置吗?

Database_Properties Server_Properties

由于

3 个答案:

答案 0 :(得分:2)

您正在寻找DATABASEPROPERTYSERVERPROPERTY

只需将它们列在SELECT语句中,例如:

SELECT 
 [Service_Name]                 = @@SERVICENAME
,[Server Name]                  = SERVERPROPERTY('ServerName')
,[Physical_Net_BIOS_Name]       = SERVERPROPERTY('ComputerNamePhysicalNetBIOS')
,[Edition]                      = SERVERPROPERTY('Edition')
,[Product_Version]              = SERVERPROPERTY('ProductVersion')
,[Product_Update_Reference]     = SERVERPROPERTY('ProductUpdateReference')
,[Resource_Last_Update_Date]    = SERVERPROPERTY('ResourceLastUpdateDateTime')
,[Process_ID]                   = SERVERPROPERTY('ProcessID')
,[Collation]                    = SERVERPROPERTY('Collation')
,[CLR_Version]                  = SERVERPROPERTY('BuildClrVersion')
,[Is_Clustered]                 = SERVERPROPERTY('IsClustered') 
,[Is_FullText_Installed]        = SERVERPROPERTY('IsFullTextInstalled') 
,[Is_Integrated_Security_Only]  = SERVERPROPERTY('IsIntegratedSecurityOnly')
,[File_Stream_Configured_Level] = SERVERPROPERTY('FilestreamConfiguredLevel')
,[Is_HA_DR_Enabled]             = SERVERPROPERTY('IsHadrEnabled') 
,[HA_DR_Manager_Status]         = SERVERPROPERTY('HadrManagerStatus')
,[Default_Data_Path]            = SERVERPROPERTY('InstanceDefaultDataPath')
,[Default_Log_Path]             = SERVERPROPERTY('InstanceDefaultLogPath')

添加/删除您需要的任何属性。

答案 1 :(得分:0)

我偶然发现了您的旧帖子。我为DATABASEPROPERTYEX编写了此代码,因为我需要这样做:

<html>
<head>
  <title>Vector tiles</title>

  <script src="ol.js"></script>
  <link rel="stylesheet" href="ol.css">
  <style>
    html, body {
      font-family: sans-serif;
      width: 100%;
    }
    .map {
      height: 500px;
      width: 100%;
    }
  </style>
</head>
<body>
  <h3>Mapbox Protobuf - vector tiles</h3>
  <div id="map" class="map"></div>
  <script>

  var style_simple = new ol.style.Style({
    fill: new ol.style.Fill({
      color: '#ADD8E6'
    }),
    stroke: new ol.style.Stroke({
      color: '#880000',
      width: 1
    })
  });

  function simpleStyle(feature) {
    return style_simple;
  }

  var layer = 'myState:State';
  var projection_epsg_no = '900913';
  var map = new ol.Map({
    target: 'map',
    view: new ol.View({
      center: [0, 0],
      zoom: 2
    }),
    layers: [new ol.layer.VectorTile({
      style:simpleStyle,
      source: new ol.source.VectorTile({
        tilePixelRatio: 1, // oversampling when > 1
        tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
        format: new ol.format.MVT(),
        url: 'http://localhost:8080/geoserver/gwc/service/wtms/1.0.0/' + layer +
            '@EPSG%3A'+projection_epsg_no+'@pbf/{z}/{x}/{-y}.pbf'
      })
    })]
  });
  </script>
</body>
</html>

答案 2 :(得分:0)

declare @dbname varchar(max)='adventureworks2016ctp3' 
select 'name' as feature, cast(name as sql_variant) as " value" from sys.databases where name=@dbname 
union select 'database_id', cast(database_id as sql_variant) as " value" from sys.databases where name=@dbname 
union select 'source_database_id', cast(source_database_id as sql_variant) as " value" from sys.databases where name=@dbname
union select 'owner_sid', cast(user_name(owner_sid) as sql_variant) as " value" from sys.databases where name=@dbname
union select 'create_date', cast(create_date as sql_variant) as " value" from sys.databases where name=@dbname
union select 'compatibility_level', cast(compatibility_level as sql_variant) as " value" from sys.databases where name=@dbname
union select 'collation_name', cast(collation_name as sql_variant) as " value" from sys.databases where name=@dbname 
union select 'user_access', cast(user_access as sql_variant) as " value" from sys.databases where name=@dbname 
union select 'user_access_desc', cast(user_access_desc as sql_variant) as " value" from sys.databases where name=@dbname 
union select 'is_read_only', cast(is_read_only as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_auto_close_on', cast(is_auto_close_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_auto_shrink_on', cast(is_auto_shrink_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'state', cast(state as sql_variant) as " value" from sys.databases where name=@dbname
union select 'state_desc', cast(state_desc as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_in_standby', cast(is_in_standby as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_cleanly_shutdown', cast(is_cleanly_shutdown as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_supplemental_logging_enabled', cast(is_supplemental_logging_enabled as sql_variant) as " value" from sys.databases where name=@dbname
union select 'snapshot_isolation_state', cast(snapshot_isolation_state as sql_variant) as " value" from sys.databases where name=@dbname
union select 'snapshot_isolation_state_desc', cast(snapshot_isolation_state_desc as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_read_committed_snapshot_on', cast(is_read_committed_snapshot_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'recovery_model', cast(recovery_model as sql_variant) as " value" from sys.databases where name=@dbname
union select 'recovery_model_desc', cast(recovery_model_desc as sql_variant) as " value" from sys.databases where name=@dbname
union select 'page_verify_option', cast(page_verify_option as sql_variant) as " value" from sys.databases where name=@dbname
union select 'page_verify_option_desc', cast(page_verify_option_desc as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_auto_create_stats_on', cast(is_auto_create_stats_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_auto_create_stats_incremental_on', cast(is_auto_create_stats_incremental_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_auto_update_stats_on', cast(is_auto_update_stats_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_auto_update_stats_async_on', cast(is_auto_update_stats_async_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_ansi_null_default_on', cast(is_ansi_null_default_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_ansi_nulls_on', cast(is_ansi_nulls_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_ansi_padding_on', cast(is_ansi_padding_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_ansi_warnings_on', cast(is_ansi_warnings_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_arithabort_on', cast(is_arithabort_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_concat_null_yields_null_on', cast(is_concat_null_yields_null_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_numeric_roundabort_on', cast(is_numeric_roundabort_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_quoted_identifier_on', cast(is_quoted_identifier_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_recursive_triggers_on', cast(is_recursive_triggers_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_cursor_close_on_commit_on', cast(is_cursor_close_on_commit_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_local_cursor_default', cast(is_local_cursor_default as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_fulltext_enabled', cast(is_fulltext_enabled as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_trustworthy_on', cast(is_trustworthy_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_db_chaining_on', cast(is_db_chaining_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_parameterization_forced', cast(is_parameterization_forced as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_master_key_encrypted_by_server', cast(is_master_key_encrypted_by_server as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_query_store_on', cast(is_query_store_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_published', cast(is_published as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_subscribed', cast(is_subscribed as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_merge_published', cast(is_merge_published as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_distributor', cast(is_distributor as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_sync_with_backup', cast(is_sync_with_backup as sql_variant) as " value" from sys.databases where name=@dbname
union select 'service_broker_guid', cast(service_broker_guid as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_broker_enabled', cast(is_broker_enabled as sql_variant) as " value" from sys.databases where name=@dbname
union select 'log_reuse_wait', cast(log_reuse_wait as sql_variant) as " value" from sys.databases where name=@dbname
union select 'log_reuse_wait_desc', cast(log_reuse_wait_desc as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_date_correlation_on', cast(is_date_correlation_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_cdc_enabled', cast(is_cdc_enabled as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_encrypted', cast(is_encrypted as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_honor_broker_priority_on', cast(is_honor_broker_priority_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'replica_id', cast(replica_id as sql_variant) as " value" from sys.databases where name=@dbname
union select 'group_database_id', cast(group_database_id as sql_variant) as " value" from sys.databases where name=@dbname
union select 'resource_pool_id', cast(resource_pool_id as sql_variant) as " value" from sys.databases where name=@dbname
union select 'default_language_lcid', cast(default_language_lcid as sql_variant) as " value" from sys.databases where name=@dbname
union select 'default_language_name', cast(default_language_name as sql_variant) as " value" from sys.databases where name=@dbname
union select 'default_fulltext_language_lcid', cast(default_fulltext_language_lcid as sql_variant) as " value" from sys.databases where name=@dbname
union select 'default_fulltext_language_name', cast(default_fulltext_language_name as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_nested_triggers_on', cast(is_nested_triggers_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_transform_noise_words_on', cast(is_transform_noise_words_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'two_digit_year_cutoff', cast(two_digit_year_cutoff as sql_variant) as " value" from sys.databases where name=@dbname
union select 'containment', cast(containment as sql_variant) as " value" from sys.databases where name=@dbname
union select 'containment_desc', cast(containment_desc as sql_variant) as " value" from sys.databases where name=@dbname
union select 'target_recovery_time_in_seconds', cast(target_recovery_time_in_seconds as sql_variant) as " value" from sys.databases where name=@dbname
union select 'delayed_durability', cast(delayed_durability as sql_variant) as " value" from sys.databases where name=@dbname
union select 'delayed_durability_desc', cast(delayed_durability_desc as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_memory_optimized_elevate_to_snapshot_on', cast(is_memory_optimized_elevate_to_snapshot_on as varchar(60)) as " value" from sys.databases where name=@dbname
union select 'is_federation_member', cast(is_federation_member as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_remote_data_archive_enabled', cast(is_remote_data_archive_enabled as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_mixed_page_allocation_on', cast(is_mixed_page_allocation_on as sql_variant) as " value" from sys.databases where name=@dbname
union select 'is_temporal_history_retention_enabled', cast(is_temporal_history_retention_enabled as varchar(70)) as " value" from sys.databases where name=@dbname