Hai,
Anda ingin mempelajari semua Inventaris SQL Server saat Anda terhubung ke database SQL Server untuk pertama kalinya.
Inventarisasi Database SQL Server ini terdiri dari informasi berikut.
- Nama Mesin
- Nama Instance
- Nama Server SQL
- Nama Basis Data
- Pemilik
- Kompatibilitas
- Nama Koleksi
- IS_auto_close_on
- IS_auto_shrink_on
- IS_in_standby
- Halaman_verifikasi_option_desc
- Negara Bagian
- IS_auto_create_stats_on
- IS_auto_update_stats_on
- IS_auto_update_stats_async_on
- Total Ukuran Log Basis Data
- Total Log Basis Data yang Digunakan
- Total ukuran file Data Basis Data
Kueri seperti berikut, itu akan membuat pekerjaan Anda sangat sederhana saat Anda terhubung ke database SQL Server untuk pertama kalinya.
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