Monday, April 28, 2008

How to get a list of all databases and database files in SQL Server 2005



Reference:
http://msdn2.microsoft.com/en-us/library/ms180163.aspx

There are a number of ways to get SQL Server 2005 database list and other database information. Some of them are shown in this video clip and listed here for easy copy and paste:

  • Select * from sys.databases;

  • Select * from sys.sysdatabases; (This SQL Server 2000 system table is included as a view for backward compatibility)

  • Select * from sys.database_files;

  • Select * from sys.master_files;

  • EXEC sp_databases;

  • EXEC sp_helpdb;

  • SELECT DATABASEPROPERTYEX('master', 'Status') DatabaseStatus_DATABASEPROPERTYEX;

No comments: