TSQL Circle Live

Find Most executed queries

SELECT TOP 50
QueryState.execution_count
,OBJECT_NAME(objectid)
,query_text = SUBSTRING(
qt.text,
QueryState.statement_start_offset/2,
(CASE WHEN QueryState.statement_end_offset = -1
THEN len(convert(nvarchar(max), qt.text)) * 2
ELSE QueryState.statement_end_offset
END - QueryState.statement_start_offset)/2)
,qt.dbid
,dbname = db_name(qt.dbid)
,qt.objectid
FROM sys.dm_exec_query_stats QueryState
CROSS APPLY sys.dm_exec_sql_text(QueryState.sql_handle) as qt
ORDER BY...

2018-09-18

185 reads

Get all queries running against any specific table

/*Get list of all queries hitting any specific tables*/SELECT DISTINCT TOP 100ProcedureName = OBJECT_SCHEMA_NAME(sqlTxt.objectid) + '.' + OBJECT_NAME(sqlTxt.objectid),SQLStatement = SUBSTRING(sqlTxt.Text,(QueryState.statement_start_offset/2)+1,CASE QueryState.statement_end_offsetWHEN -1 THEN DATALENGTH(sqlTxt.text)ELSE QueryState.statement_end_offsetEND...

2018-09-18

148 reads

Blogs

Reviewing 2019 Career Goals

By

According to this post, I rate 2019 as a Failure. Of the books I...

ASF 029: Tomaz Kastrun interview

By

Introduction Tomaž Kastrun is BI & DEV developer, data analyst & data science. With...

Schema Filtering in SQL Prompt

By

I love SQL Prompt, and I’m regularly impressed by the enhancements our teams continue...

Read the latest Blogs

Forums

Automatic Redaction of PII

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Automatic Redaction of PII

Find Strings Containing Hex Range

By phobia42

I have a table with a varchar field.  It contains a number of characters...

How to implement row last access date column

By xr280xr

I'm creating a table to store serialized shopping cart data associated with a user...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers