Latest Posts
📅 2019-02-11
✍️ Bart Schelstraete
Sometimes you need to know when a SQL login was created. The SQL code below will list the SQL logins, when they were created, and whether they are enabled or disabled. SELECT 'Server[@Name=' +…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
The T-SQL code below will give you the top 10 most CPU-consuming SQL statements in your database, sorted by CPU time. SELECT TOP 10 qs.total_worker_time/qs.execution_count as [Avg CPU Time],…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Disk I/O is most of the time the bottleneck of your SQL database, even when using SSD. The SQL statement below will show you the most disk I/O-intensive statements, which you should look to improve.…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
The code below will give you the top 10 most executed stored procedures in your database, sorted by execution count. SELECT TOP 10 dest.text, deqs.execution_count, deqs.total_worker_time,…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Interested in seeing how long your SQL Server Agent has been up and running, or want to check if that agent is operational? You can use the T-SQL code below to find out: SET NOCOUNT ON DECLARE…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
The SQL statement below will give you the top 100 longest running SQL statements in your database, sorted by duration. SELECT TOP 100 qs.total_elapsed_time / qs.execution_count / 1000000.0 AS…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Looking for a table, but you don't remember which database it's located in? The code below will create a stored procedure, which you can use to find a table across multiple databases. CREATE…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
You can use the T-SQL code below to display the size of each table in a specific database. use MY_DATABASE_NAME go EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'" go
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Sometimes you need to do maintenance on a database, and you don't really want to use single-user mode or disable accounts. In that situation you could kill all connections to a specific database. In…
Read more →
📅 2017-11-20
✍️ Bart Schelstraete
You can use the following shell commands to redirect a port to another port. PORT_FROM=443 PORT_TO=443 DEST=10.33.35.110 iptables -t nat -A PREROUTING -p tcp --dport $PORT_FROM -j DNAT --to…
Read more →