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

409 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

789 reads

Blogs

Using Framing for a Running Total–#SQLNewBlogger

By

Another post for me that is simple and hopefully serves as an example for...

Accessibility in your PowerPoint slide deck

By

This post is part of the series I kicked off here. You can read...

Daily Coping 28 Jul 2021

By

I started to add a daily coping tip to the SQLServerCentral newsletter and to...

Read the latest Blogs

Forums

Conditional Update of Column

By Phil Parkin

I can't remember ever trying this before, but I have need to do it...

BulkCopy error

By Bruin

I'm trying to load a csv to SQL using the BULKCOPY, but running into...

Login failed: Password did not match that for the login provided.

By tom 69406

I just installed a new instance of SQL Developer Edition - All my apps...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers