Within a Stored Procedure, you may want the results of a particular query emailed to…
Category: SQL Server
SQL Server Profiler New Templates Failing
Source of info: http://www.mattbutton.com/2011/06/01/sql-profiler-templates-missing/ Upon trying to create a trace template in SQL Server Profiler, I…
TSQL – Simple Loop Through Result Set Using Cursor
This is the basic query text to use whenever you need to loop through a…
Rolling Back Dynamic SQL
Do transactions apply in dynamic SQL, in SQL Server? In a word, yes. For proof,…
SQL Server – Find Missing Indexes With Script In Output
Source: http://sqlserverplanet.com/dmvs/missing-indexes-dmv SELECT mid.statement ,migs.avg_total_user_cost * (migs.avg_user_impact / 100.0) * (migs.user_seeks + migs.user_scans) AS improvement_measure…
SQL Server – Download all RDL files from Report Server
—- Allow advanced options to be changed. –EXEC sp_configure ‘show advanced options’, 1 –GO —-…
PowerShell – Query Database Remotely
The basic syntax for sending a query to SQL Server using PowerShell. sqlcmd -S SERVER_NAME…
PowerShell – Get All SQL Server Instances In Environment
cls import-module failoverclusters Import-Module -Name SQLPS -DisableNameChecking $servers = “comma”,”separated”,”server”,”list” foreach($server in $servers) { try…
Fixing Orphaned Users On A Large Scale
A script that generates a script to fix all orphaned users at once.
Recovering a database in RESTORING state
How to get your database out of the “restoring” state so you can use it again.