How to find Active Databases?

  • Hello,

    I want to find out active databases in SQL Server with one sql query

    select name from sysdatabases where status ....

    This query should return only active databases but not the databases which are undergoing restore,offline etc..I mean i should get the database names which are available to users to use.

    Thanks

  • Read about sysdatabases system table in BOL.

    Everything is there.

    _____________
    Code for TallyGenerator

  • sp_helpdb returns database name and status.  Look for Status=ONLINE.

    Greg

    Greg

  • select *

    from master.dbo.sysdatabases

    where DATABASEPROPERTYEX(name, 'Status') = 'OnLine'

    _____________
    Code for TallyGenerator

  • Thanks sergiy...

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply