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

309 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

246 reads

Blogs

The End of PASS

By

I think our profession was the better for having a professional association, even if...

Platforms for Events

By

in my last post I wrote about thinking of the tools as being a...

Getting Started with Robotic Process Automation (RPA) Using the Power Automate Desktop

By

There are a lot of hot phrases you’ve likely heard thrown around during various...

Read the latest Blogs

Forums

"Home PC" SQL instance

By ifthir

This may be a bit non-typical, but I am currently running SQL 2019 Developer...

delete

By sulman.sqldba

    delete

Interview question about CPU

By Lord Slaagh

Hello SSC friends, I am a SQL Developer who is learning how to be...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers