List Databases MSSQL

To list all databases on a Microsoft SQL Server (or MSDE, of course) via OSQL or whatever, use this:

exec sp_helpdb

However, that spits out really wide columns of data that are awkward in an interactive OSQL session... this option is easier to read, but it is unsupported:

SELECT name FROM master..sysdatabases ORDER BY name



To list the logical files in a sql server database in interactive OSQL sessions, try this:

Use mydb;
select * from sysfiles;


Some other options:

tags: SQL, Server, MSSQL, osql

Related Scribbles:
  • Attach / Detach Database OSQL Example
  • SQL Server - Move a database manually via SQL
  • Restore and Backup MSDE Database with TSQL via OSQL
  • Quickly Shrink SQL Server Transaction Logs
  • SQL Server

  • ID: 726
    Date Updated:
    2010-09-16 15:00:04
    Date Created:
    2005-12-24 16:13:03


     >> Leonard Chan's Homepage  >> Scribble Web  >> List Databases MSSQL is hosted by Perceptus Solutions Inc.