Wednesday, 15 February 2017

How to check the Log Space of a database in SQL server ?

In SQL Server maintaining the transaction log is a big challenge and as a DBA we always need to monitor the space used by the transaction log file.

Here you can check the log space of the transaction log file using the following command.

DBCC SQLPERF (LOGSPACE)

So the above command will display the size of the log file and percentage of log space used.

Tuesday, 14 February 2017

How to find the SQL Server Last Restarted date & time ?

One of the easiest way to find when SQL server was restarted is using Dynamic Management view (DMV).

In some of the scenarios we need to know when the SQL server was restarted.

DMV

SELECT * FROM SYS.DM_OS_SYS_INFO

Example

I have taken the Sqlserver_start_time column from the above view.

So now my SQL server instance restarted time is 2017-02-08.

Sunday, 12 February 2017

Types of Recovery Models available in SQL Server ?

In SQL server there are 3 different types of recovery models.
Each database mush be selected to any of these 3 recovery models.

Following are the types of recovery models used in SQL server.

Simple
Full
Bulk-Logged

T-SQL to change the recovery model of a database

ALTER DATABASE DATABASE_NAME
SET RECOVERY [Full / Simple / Bulk-Logged]