Useful SQL Scripts

Performance freak
Search for a command to run...

Performance freak
No comments yet. Be the first to comment.
When you use Response.Redirect with its second parameter set to true, it triggers a call to Response.End() Response.Redirect("Login.aspx"); // default is true Response.Redirect("Login.aspx", true); // same as above This causes AS...

Using ThreadPool.QueueUserWorkItem: Helps bypass limitations when trying to run async code inside IHttpModule. Does not interfere with the ASP.NET pipeline. Email sending does not block the main thread. Calling SendMailAsync().Wait() is safe here...

Introduction In SQL Server, the bit data type is used to store boolean values (0 for false, 1 for true). However, when working with SQL Server in a .NET application using Entity Framework or LINQ to SQL, the bit field is automatically converted to a ...

System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() To avoid the ThreadAbortException error when using Response.Redirect, setting the second parameter to false is generally sufficient. However,...

In Visual Studio; Solution Explorer-Project-Properties-Application. Check "Auto-Generate binding redirects" When this is selected, versions are specified in the web.config file after the Nuget package updates. When is binding necessary? If there is...

DECLARE @SearchForSql AS NVARCHAR(MAX) = 'Company'
SELECT UseCounts, Cacheobjtype, Objtype, TEXT, query_plan
FROM sys.dm_exec_cached_plans
CROSS APPLY sys.dm_exec_sql_text(plan_handle)
CROSS APPLY sys.dm_exec_query_plan(plan_handle)
WHERE Text LIKE CONCAT('%',@SearchForSql,'%')
AND Text NOT LIKE '%-- Self Reference Marker --%'
SELECT o.NAME,
i.rowcnt
FROM sysindexes AS i
INNER JOIN sysobjects AS o ON i.id = o.id
WHERE i.indid < 2 AND OBJECTPROPERTY(o.id, 'IsMSShipped') = 0
ORDER BY 2 desc
SELECT TOP 50
q.query_hash,
qt.query_sql_text,
cast(p.query_plan as xml) query_plan,
rs.execution_type,
rs.execution_type_desc,
rs.count_executions,
rs.last_execution_time,
(rs.avg_duration / 1000000.0) avg_duration_seconds,
(rs.min_duration / 1000000.0) min_duration_seconds,
(rs.max_duration / 1000000.0) max_duration_seconds,
(rs.last_duration / 1000000.0) last_duration_seconds
FROM sys.query_store_query AS q
JOIN sys.query_store_plan AS p on q.query_id = p.query_id
JOIN sys.query_store_query_text AS qt on q.query_text_id = qt.query_text_id
JOIN sys.query_store_runtime_stats rs on p.plan_id = rs.plan_id
WHERE rs.execution_type = 3
ORDER BY rs.last_execution_time DESC;