For Retrieving all Databases information

There are three methods for retrieving data base information in sql server.


EXEC sp_databases

EXEC sp_helpdb

SELECT * 
FROM sys.sysdatabases
order by name


Comments

  1. SELECT distinct
    'DB_NAME' = db.name
    --'FILE_NAME' = mf.name,
    --'FILE_TYPE' = mf.type_desc,
    --'FILE_PATH' = mf.physical_name
    FROM
    sys.databases db
    INNER JOIN sys.master_files mf
    ON db.database_id = mf.database_id
    WHERE
    db.state = 6 --Offline

    ReplyDelete

Post a Comment

Popular posts from this blog

TSQL To Get All the Names of tables and Databases whose data have changed in last 24 Hours

To Get All the Names of tables and Databases their data have changed in last 24 Hours And Backup those databases

Apply paging in procedure