Posts

Showing posts from January, 2015

Backing up a complete database

This script will take a full database backup to disk BACKUP DATABASE AdventureWorks2012 TO DISK = 'T:\Backups\AdvWorksData2015.bak' WITH FORMAT; GO Although there are other options available in the backup database command, this one is the simplest. Nothing geeky in the new year post :)

SQL SERVER - Find the Size of Database

I encountered the situation recently where I needed to find the size of the database log file while doing baseline.  Here is the script, if you remove the WHERE condition you will find the result for all the databases. SELECT  DB_NAME ( database_id )  AS  DatabaseName , Name  AS  Logical_Name , Physical_Name , ( size * 8 )/ 1024 SizeMB FROM  sys.master_files WHERE  DB_NAME ( database_id ) = 'AdventureWorks'-- substitute the name of DB here GO