SQL Server

How to get list of the most expensive queries in SQL Server

SELECT TOP 20 (total_logical_reads + total_logical_writes) / execution_count AS AverageIO ,(total_logical_reads + total_logical_writes) AS TotalIO ,qt.text Query ,o.name ObjectName ,DB_NAME(qt.dbid) AS DATABASEName FROM sys.dm_exec_query_stats qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt LEFT OUTER JOIN sys.objects o ON o.object_id = qt.objectid ORDER… Read More ›

Update from in SQL Server (lookup)

USE Arm_DB Go CREATE TABLE TBL_ARM1 ( ID INT IDENTITY(1,1) ,Title Nvarchar(50) ) Go CREATE TABLE TBL_Arm2 ( ID INT Identity(1,1) ,Name Nvarchar(50) ,Arm1_ID Int ,Arm_Title Nvarchar(50) ) GO INSERT INTO TBL_ARM1 VALUES (‘Arm1_1’) INSERT INTO TBL_ARM1 VALUES (‘Arm1_2’) INSERT… Read More ›