Archive for November, 2011

Detect and Kill Session/ Exclusively Locked Session in SQL Server using SQL

This following query retrieves active Sessions in specific Database.


-- Get Active Sessions 
SELECT DISTINCT
        name AS database_name,
        session_id,
        host_name,
        login_time,
        login_name,
        reads,
        writes
FROM    sys.dm_exec_sessions
        LEFT OUTER JOIN sys.dm_tran_locks ON sys.dm_exec_sessions.session_id = sys.dm_tran_locks.request_session_id
        INNER JOIN sys.databases ON sys.dm_tran_locks.resource_database_id = sys.databases.database_id
WHERE resource_type <> 'DATABASE'
--AND name ='Your Database Name'
ORDER BY name

Continue reading

Advertisements

SQL Server Schedule Jobs

Here, I will share some screenshots to show how to set up SQL Server Jobs using SQL server Management Studio.
SQL Server Schedule Jobs Step 1
Step 1: Create New Job. Continue reading