Top 10 SQL Administrators Scripts You Should Know (link)
Top 10 SQL Scripts You Should Know Views – 1743
Read MoreTop 10 SQL Scripts You Should Know Views – 1743
Read MoreUsers frequently want spreadsheets with embedded links to web pages, one per row. This is one way to get them.
1 2 |
SELECT '=HYPERLINK("http://website/somepage.aspx?id=' + CAST(Myid AS VARCHAR) + '", "' + CAST(Myid AS VARCHAR) + '")' AS linkToItem FROM MyTable |
Views –…
Read MoreUsing SQL Profiler to trace a Stored Procedure call Views – 1767
Read MoreYou can use this T-SQL to get the plan handle for a sproc that has a bad execution plan:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SELECT OBJECT_NAME(st.objectid,st.dbid) AS ObjectName, cp.usecounts AS ExecutionCount, cp.cacheobjtype AS ObjectType, cp.plan_handle AS PlanHandle, deps.cached_time as CachedDate, deps.last_execution_time AS LastExecuted, deps.total_worker_time AS TotalWorkerTime, st.TEXT AS QueryText, qp.query_plan AS QueryPlan, GETDATE() AS TimeQueryExecuted FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st INNER JOIN sys.dm_exec_procedure_stats deps ON deps.plan_handle = cp.plan_handle WHERE cp.objtype = 'Proc' AND OBJECT_NAME(st.objectid,st.dbid) = 'usp_SomeSproceName'; |
Make sure, to…
Read More
1 2 3 4 5 6 7 8 9 10 11 12 |
SELECT OBJECT_NAME(st.objectid,st.dbid) AS ObjectName, cp.usecounts AS ExecutionCount, st.TEXT AS QueryText, qp.query_plan AS QueryPlan FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st WHERE cp.objtype = 'Proc' AND OBJECT_NAME(st.objectid,st.dbid) = 'YourStoredProcedure'; |
Views – 2114
Read MoreSetting ANSI_NULLS ON will make make the Sprocs run fast. See this article: Query is fast but Sproc is slow Views – 1722
Read MoreHere is a great article on trouble-shooting T-SQL query slowness: Trouble-shooting SQL Server Slowness Views – 1722
Read MoreUpdates query optimization statistics on a table or indexed view. By default, the query optimizer already updates statistics as necessary to improve the…
Read MoreClustered Clustered indexes sort and store the data rows in the table or view based on their key values. These are the columns…
Read MoreSQL Server-level Roles • SysAdmin: Allows users to perform any activity on the server. • ServerAdmin: Permits users to manage configuration options on…
Read More