I have probably in excess of 100 databases on this one SQL Server (2005) instance. I'd like to list them in order of their create dates, or even better, in the order of the date of the latest modification to any table.
Is there a SELECT query I can write, and just as importantly, from what context do I write it and with what permissions do I need to execute it?
The command to see system databases are : SELECT name, database_id, create_date FROM sys.
If you need to check a single database, you can quickly find the SQL Server database sizein SQL Server Management Studio (SSMS): Right-click the database and then click Reports -> Standard Reports -> Disk Usage. Alternatively, you can use stored procedures like exec sp_spaceused to get database size.
You can easily write this query against the sys.databases
catalog view
SELECT * FROM sys.databases
ORDER BY create_date
but unfortunately, there's no equivalent for the "last modification date" that I'm aware of ...
This should work from any database on that server - doesn't matter which database you're in, those sys
catalog views should be accessible from anywhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With