Tag: Database Admin
-
How to Backup a SQL Server Database
This post contains a demo on how to backup a SQL Server Database and includes some information on the types of backups available in MS SQL. The 3 types of backups that will be covered in this post are:# MS SQL Full Backup# MS SQL Transaction Log Backup# MS SQL Differential Backup Before backing up…
-
Get Estimated Backup Restore Time in SQL Server
This post contains a SQL script to get estimated completion times and process information for your currently running database backups & restores in SQL Server. Backing up a database can often take a very long time. It depends on various factors why a backup can take longer to complete. One more obvious reason is, that…
-
How to Get Last Backup Times for all Databases in SQL Server
This is a post on how to get the last backup dates and times for all databases on a SQL Server Instance. Database backups are as important as the availability of your server. If your database gets corrupted, or there’s an accidental data deletion and you need to recover data, then we must rely on…
-
Drop Table if Exists in SQL Server
The DROP TABLE command in SQL Server will do as it suggests and drops a table. This post is to show an example of using this command, including the IF EXISTS argument. DROP TABLE IF EXISTS in MS SQL allows us to conditionally drop the table, meaning it does not cause an error if the…
-
Get Last Database Restore DateTimes in SQL Server
This post contains a script to help you get the last dates and times for when your databases were last restored in SQL Server. The script below queries the M.S.D.B database sys.databases and restorehistory tables. You should get into the habit of searching MS Docs for every system table you query in SQL Server. This…
-
List All SQL Agent Jobs on a SQL Server Instance
This post contains a SQL script that will return a list of all SQL Server Agent Jobs on a Microsoft SQL Server instance. The sysjobs and sysjobsteps tables we are querying are in the M-S-D-B database. Interesting fact, I am unable to publish a post with this actual database name without seeing a JSON error.…
-
How to Restore a Database in SQL Server
Restoring a database in SQL Server is a straightforward task, and one that SQL Database Administrators have to perform thousands of times throughout their career. A database restore can be done via GUI (SSMS Wizard) or via command (TSQL/PowerShell). The method you choose to restore a database is usually driven by the number of databases…
-
Why Use WHERE 1=2 in SQL
Some time ago I wrote a blog post on why use WHERE 1=1 in SQL. This time it’s why use WHERE 1=2, but really this can be WHERE 1=9 or anything that isn’t a 1, we just want the false statement. WHERE 1=1 is TRUE; has no difference on execution times and can be used…
-
Get All Database Sizes & Free Space Info In SQL Server
Tracking database file sizes and free space within data and log files is an important part of monitoring SQL Server. This information, along with other metrics such as growth events, can help you to better predict and plan for future disk space provisioning needs. The following script provides a quick way to view database file…
-
Change Default Database in SQL Server
When you log into SQL Server using SQL Server Management Studio (SSMS), opening a new query window will automatically scope you within the default database set when your user was created. If this isn’t explicitly set during creation it’ll be set to the master database which isn’t very convenient for users. DBA’s might have to…
Recent Posts
- How to Open SSMS as a Different Domain User
- Troubleshooting Database Mirroring Issues in SQL Server
- What’s New in SQL Server 2025
- Time To Revive This Blog
- How to Set Environment Variables in PowerShell
Categories
- AWS (5)
- DBA Stories (1)
- Linux (34)
- MySQL (5)
- Other (2)
- Postgres (7)
- PowerShell (48)
- RedShift (7)
- SQL Server (81)
- Windows Admin (64)
Tags
Active Directory (AD) AWS CLI CDC Certificates & Encryption Change Data Capture CSV Files Database Admin Database Backups Data Types Deleting Data Error Messages Featured Git Git Commands Git Log Installing SQL Server Linked Servers Linux Admin Measuring Databases MSSQL SPIDs NetFirewallProfile New-Item PowerShell PowerShell Create Folder PowerShell Delete Files PowerShell ForEach PowerShell Tips PowerShell Version Restoring Databases SQL Server Agent SQL Server ETL SQL Server Management Studio (SSMS) SQL Server Processes SQL Server Scripts SQL Tips SSH SSMS Tips Temp DB Windows Admin Windows Firewall WordPress Tutorials WSL WSL1 WSL2 WSL Ubuntu WSL Version