MSSQL

USE [master];
DECLARE @kill varchar(8000) = ”;
SELECT @kill = @kill + ‘kill ‘ + CONVERT(varchar(5), req_spid) + ‘;’
FROM master.dbo.syslockinfo
WHERE rsc_type = 2
AND rsc_dbid = db_id(‘MyDB’)
EXEC(@kill);

Back up and shrink the Microsoft SQL transaction log and release the unused space

 

How to back up the transaction log file:

  1. In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
  2. Expand Databases and then right-click the database that you want to back up.
  3. Point to Tasks, point to Back Up, and then in General page click Backup type.
  4. In Options page ensure Truncate the transaction log option is selected

  

  

 

 

How to shrink a log file:

  1. In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
  2. Expand Databases and then right-click the database that you want to shrink.
  3. Point to Tasks, point to Shrink, and then click Files.
  4. Select the file type and file name.
  5. Optionally, select the Release unused space check box.

Selecting this option causes any unused space in the file to be released to the operating system and shrinks the file to the last allocated extent. This reduces the file size without moving any data.

 

Scroll to top