21 Mar 2012

The Accidental DBA Survival Kit - Part 1

I occasionally get drawn into some DBA related tasks, so yes I'm an "Accidental DBA" and I've decided to start compiling the snippets of code that I often have to use.

How to get a quick overview of a database

USE Database Name
EXEC sp_helpfile

Getting out of a Transaction Log 'Bear Trap'  


The following T-SQL can be used if you have exhausted your Transaction Log disk space and you have no other way either granting additional space. ***Warning this will break the transaction log chain***
USE DatabaseName
GO
DBCC SHRINKFILE(TransactionLogName, 1)
BACKUP LOG DatabaseName WITH TRUNCATE_ONLY
DBCC SHRINKFILE(TransactionLogName, 1)
GO

Update 1:


View all Databases on a SQL Server

EXEC sp_databases
View all Databases and some brief information
 EXEC sp_helpdb

No comments: