One of the most frequent questions which I receive from my client is about activity going inside SQL Server and how to list all sessions.
Attach an In-Memory Database With T-SQL: Include the Container
To attach an In-Memory database with T-SQL, use CREATE DATABASE with FOR ATTACH and list the data file, the log file and, when it moved, the container folder. This post builds a demo database, detaches it and attaches it twice. It also shows which rows survive.
SQL SERVER – Attach a Database with T-SQL
To attach a Database with T-SQL, I use CREATE DATABASE … FOR ATTACH. A customer asked about attaching existing data and log files.
Capture sp_who2 Output Into a Table With INSERT EXEC
To capture sp_who2 output, create a table with matching columns and fill it with INSERT EXEC. This post builds the table, captures the session list three times with a time stamp, and shows the two errors that stop the method.
DMV Version of sp_who2: A Cleaner Session List
A DMV version of sp_who2 returns the same session details from documented views and leaves out the system tasks. This post builds the query, shows why the old spid above 50 filter fails, and stores the result in a temporary table.
Line Numbers for SSMS Efficiency – SQL in Sixty Seconds #147
This is when the line numbers in SSMS comes in extremely handy and let us learn in today’s blog post how we can do that. Let us learn today.
Finding Old Agent Jobs Not Run in Months or Never Scheduled
Review agent jobs not run recently or lacking schedules, combine history and activity, and disable approved candidates for review.
Slow Running Query – SQL in Sixty Seconds #146
One of the most popular questions I receive during Comprehensive Database Performance Health Check is if I have a script that lists Slow Running Query.
Convert Integer to Date in SQL Server: ddMMyyyy Values
To convert integer to date values such as 09122020, split the number into day, month and year and build the date from the parts. This post compares four methods on tested data, shows why a lost leading zero and the session language break two of them, and times them on a million rows.










