Blog Posts
-
Updating Help Documentation in PowerShell
The Update-Help cmdlet in PowerShell will download the latest help files for PowerShell modules installed on your machine. Running PowerShell as Administrator is a requirement for this one, else you’ll get the following error. “Access is denied” is the key part in this error, amongst a lot of…
-
Moving TempDB Files in SQL Server
It’s a solid best practise to have TempDB files stored in separate drive, away from your C: drive. This is because TempDB can grow very large, very quickly (within minutes); depending on workloads of course, and this can happen on both the TempDB data (.ndf) and log (.ldf)…
-
The SSMS Import Flat File Feature
The Import Flat File feature within SQL Server Management Studio (SSMS) was introduced in December 2017 (14.0.17213.0). This is a streamlined version of the Import Data feature and it minimises the user intervention during a file import. Unlike the Import data feature, you don’t have the option to…
-
Attaching SQL Databases Without Log Files
In a perfect world, you’d never lose a database log file. But when the unexpected happens and you urgently need the data from a database, knowing how to attach a SQL Server database without its log (.ldf) file can be a lifesaver. This guide walks you through the…
-
Backup & Restore (WITH FILE)
In this post I’m going to show what the WITH FILE = X option does when backing-up or restoring a SQL Server database. microsoft_documentation The first thing we need to know is that a backup file can contain multiple databases, and even multiples of the same database. If you…
-
Applying Data Retention to a SQL Table
In SQL Server, there’s often a need to delete old data from a database table. This could be for reasons like adhering to GDPR policies, managing oversized tables that are slowing down operations, staying within SQL Server Express’s 10GB limit, or simply cleaning up application logs and errors.…
-
Using Custom Connection Colours in SSMS
SQL Server Management Studio (SSMS) is the tool that most SQL Server user queries are run from. It has an option that allows you to change the colour of your query banner, which is useful if you want visually mark a server that you work with every day.…
-
Counting Rows within CSV Files using PowerShell
This post contains a script that will help count rows within multiple CSV files using PowerShell. If you have a directory containing many CSV files, this’ll help you count the rows of each CSV file within the folder. Counting rows within CSV files may be useful for verifying…
-
Exporting SQL Server Query Results to CSV
This guide explains how to export a SQL Server query results to a CSV file using SSMS. SQL Server Management Studio (SSMS) is the primary tool used for managing SQL Server databases and running queries. By default, SSMS exports data in a column-aligned format, but to export data…
-
How to Check Table Sizes in SQL Server
There are many ways to check the size of a table in SQL Server. The way you will do it will likely depend on what your task at-hand is. For example, a quick look at the Disk Usage by Top Tables report on a database you’ve never seen…
Useful SQL DBA Scripts
Performance
– Quick Performance Troubleshooting Scripts
– Get Current User Activity & Blocking
– Get Wait Stats & Top Consuming Queries
– Get Database Sizes & Space Used
– Identify Missing & Unused Indexes
High Availability
– Get Always On Availability Group (AAG) Latency
– Get Mirroring Status & Latency
– Get Replication Latency
– Get Last Node Blip in SQL Server FCI
Maintenance
– Get Estimated Database Backup/Restore Time
– Get Last Database Backup Dates/Times
– Get Index & Heap Fragmentation Levels
– Get Table Sizes in SQL
Security & Auditing
– Get SQL User Permissions and Roles
– Creating SQL Users on Availability Groups
– Audit Failed Login Attempts
Categories
– AWS
– DBA Stories
– Linux
– MySQL
– Other
– Postgres
– PowerShell
– Redshift
– SQL Server
– Windows Server
Tags
Always On Availability Groups (AAG) (3) Certificates & Encryption (3) Change Data Capture (CDC) (2) Database Admin (71) Database Backups & Recovery (12) Database Mirroring (2) Deleting Data (1) Error Messages (4) Git Commands (5) Importing & Exporting Data (2) Linked Servers (3) Linux Admin (2) Logging & Monitoring (1) Measuring Databases (10) Microsoft Patching (2) PowerShell Scripts (1) SQL Server Agent (4) SQL Server Database Files (1) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (14) SQL Server Network Connectivity (2) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance (5) SQL Server Permissions (1) SQL Server Processes (5) SQL Server Replication (1) SQL Server Scripts (12) Windows Admin (21) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (20)