Pages

Showing posts with label SQl. Show all posts
Showing posts with label SQl. Show all posts

Tuesday, December 17, 2013

Find delete/Update statements been executed in SqlServer

USE master; 
SELECT deqs.last_execution_time AS [Time], dest.TEXT                
AS [Query]
FROM   sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
WHERE  dest.text LIKE '%Delete%from%'
ORDER  BY deqs.last_execution_time DESC


Result:


Thursday, March 21, 2013

Find Currently Running Query- SQL SERVER


This script gives the list of sql queries running currently on SQL SERVER

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext

Wednesday, October 19, 2011

Query to find non unique column from a table

I have a users table that has over 10,000 registered users (from a database that I've inherited). The original code allows for multiple registrations with the same email address which I want to eliminate.