Find Transaction Log Space Used

To query the space used by the transaction logs use the command, use DBCC SQLPERF(LOGSPACE). The command displays the Database Name, Log Size in Mega Bytes, the % of  log file used, remember the value is not the size it is the percentage used from the actual space of the log files. The results displayed is for all databases on the SQL Server instance.

Find the script below…

DBCC SQLPERF(LOGSPACE)

Monitoring transaction log files for the free space is a one of the very important tasks for a DBA.

Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru so that, you know when there is a new blog post.

– Bru Medishetty

WAITFOR Clause

When writing T-SQL Statements, the usage of WAITFOR clause will cause a delay in the execution of the subsequent statements until the condition is met.

WAITFOR clause can be used along with Time or Delay. Let us look at them with an example.

WAITFOR DELAY

When WAITFOR DELAY is used a delay duration needs to be mentioned which is of the format HH:MM:SS format followed by one thousandth of a second’s value. In the following image the Delay value mentioned is 5 seconds, hence the execution of the next statement i.e GETDATE() is delayed for 5 seconds. Find the T-SQL code used in the example below…

SELECT GETDATE()

WAITFOR DELAY '00:00:05:000'

SELECT GETDATE()


WAITFOR TIME

When WAITFOR TIME is used, a time value needs to be mentioned which is of the format HH:MM:SS format followed by one thousandth of a second’s value. In the following image the time value mentioned is 09:11:05 AM, hence the execution of the next statement i.e GETDATE() is delayed till that time occurs. Remember that the Time value is a 24 hour format of time. Find the T-SQL code used in the example below…

SELECT GETDATE()

WAITFOR TIME '09:11:05:000'

SELECT GETDATE()

Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru so that, you know when there is a new blog post.

–Bru Medishetty