Hallo,
Sie möchten das gesamte Inventar von SQL Server erfahren, wenn Sie zum ersten Mal eine Verbindung zur SQL Server-Datenbank herstellen.
Dieses SQL Server-Datenbankinventar besteht aus folgenden Informationen.
- Maschinenname
- Instanzname
- SQL-Servername
- Datenbankname
- Eigentümer
- Kompatibilität
- Kollationsname
- IS_auto_close_on
- IS_auto_shrink_on
- IS_in_Standby
- Page_verify_option_desc
- Zustand
- IS_auto_create_stats_on
- IS_auto_update_stats_on
- IS_auto_update_stats_async_on
- Gesamtgröße des Datenbankprotokolls
- Gesamt verwendetes Datenbankprotokoll
- Gesamtgröße der Datenbankdatendatei
Die Abfrage ist wie folgt, es wird Ihre Arbeit sehr vereinfachen, wenn Sie zum ersten Mal eine Verbindung zu einer beliebigen SQL Server-Datenbank herstellen.
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