Hallo,
U wilt alle inventaris van SQL Server leren wanneer u voor de eerste keer verbinding maakt met de SQL Server-database.
Deze SQL Server-database-inventaris bestaat uit de volgende informatie.
- Machinenaam
- Instantienaam
- SQL-servernaam
- Databasenaam
- Eigenaar
- Compatibiliteit
- Collatienaam
- IS_auto_close_on
- IS_auto_shrink_on
- IS_in_standby
- Page_verify_option_desc
- Staat
- IS_auto_create_stats_on
- IS_auto_update_stats_on
- IS_auto_update_stats_async_on
- Totale database loggrootte
- Totaal gebruikt databaselogboek
- Totale grootte van databasegegevensbestand
Query's zijn als volgen, het zal uw taak zeer vereenvoudigen wanneer u voor de eerste keer verbinding maakt met een SQL Server-database.
select serverproperty('MachineName') 'machine_name' ,isnull(serverproperty('InstanceName'),'mssqlserver') 'instance_name' ,@@SERVERNAME 'sql_server_name' ,d.name 'database_name' ,suser_sname(d.owner_sid) 'owner' ,d.compatibility_level ,d.collation_name ,d.is_auto_close_on ,d.is_auto_shrink_on ,d.state_desc ,d.snapshot_isolation_state ,d.is_read_committed_snapshot_on ,d.recovery_model_desc ,d.is_auto_create_stats_on ,d.is_auto_update_stats_on ,d.is_auto_update_stats_async_on ,d.is_in_standby ,d.page_verify_option_desc ,d.log_reuse_wait_desc ,ls.cntr_value as [log size (kb)] ,lu.cntr_value as [log used (kb)] ,lp.cntr_value as [percent log used] ,ds.cntr_value as [data file(s) size (kb)] from sys.databases d inner join sys.dm_os_performance_counters as lu on lu.instance_name=d.name and lu.counter_name like N'Log File(s) Used Size (KB)%' inner join sys.dm_os_performance_counters as ls on ls.instance_name=d.name and ls.counter_name like N'Log File(s) Size (KB)%' and ls.cntr_value > 0 inner join sys.dm_os_performance_counters as lp on lp.instance_name=d.name and lp.counter_name like N'Percent Log Used%' inner join sys.dm_os_performance_counters as ds on ds.instance_name=d.name and ds.counter_name like N'Data File(s) Size (KB)%' order by d.name