System catalogs in SQL Server

System catalogs helps in getting a lot of information about the server, DBs etc.,

sys.databases – Fetch info like name, owner, creation date

sys.database_files or sys.master_files – file names, size, location, type (database or log), etc

dm_io_virtual_file_stats – SELECT * FROM sys.dm_io_virtual_file_stats(NULL, NULL)

return information on IO statistics on database files.

sp_databases – Database meta data

sp_helpdb or sp_helpdb ‘AdventureWorks’

sp_changedbowner sa – change DB owner

SELECT DB_NAME(1) – returns master, model, tempdb or resource on keep changing the names.

SELECT DB_ID(‘master’) – returns DB ID for the database

SELECT DATABASEPROPERTYEX(‘master’, ‘Status’); – returns the status id of 0 or 1 the master database indicating online or offline status

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>