Check if PowerShell is Installed on SQL Server

Many database related tasks can be automated using PowerShell. This T-SQL script can be used to check the following:
Is PowerShell installed on your local SQL Server?
Is it enabled for script execution?
What is the version of PowerShell installed on your machine?
You can obtain all the above information using the below T-SQL script. Since we have to obtain information from the server registry and from the output of PowerShell.exe file, we will be using both sys,xp_regread and xp_cmdshell extended stored procedures in this example:

Server side lightweight SQL Server tracing

There are times when you would want to capture database activity and the most popular tool that database engineers use is SQL Server Profiler. Note: SQL Server profiler has been deprecated and it is recommended to use Extended Events for tracing any database related activity. However, in this article, we will look into how we can use SQL Server profiler without the need to run from the SQL Server Profiler tool and how we can minimize the performance impact by creating a server side trace.

T-SQL Script to Update Statistics

Index Statistics are important for query optimizer to generate optimal query plans. If indexes have outdated or stale statistics, your query's performance will suffer. It is important to update the statistics to make sure query optimizer always generates the best and...

T-SQL Script to Attach and Detach Databases

DBAs and Developers at times may need to detach and attach the databases for various reasons including the following: 1. Moving files to other drives 2. Server migration 2. Upgrades, 3. system maintenance, etc. This script takes away the headache of remembering the...