Category: SQL
When developing an application that connects to a SQL Server (or Azure SQL) database, you will often want to leverage the features that the database engine provides to help minimise checks that would otherwise need to be performed at the application level. By delegating these checks to the database, you can simplify your application logic,…
InSQL
Sometimes duplicate data can make its way into a database, whether it be due to a software defect or as the result of an error that one or more users have made. Regardless of the cause, you may find yourself in a position where you need to find and delete duplicate records from a database….
InSQL
When working in a SQL Server or Azure SQL database containing many tables, I often find the need to search for tables with names that contain a specific keyword. This is particularly true when working with an unfamiliar schema. While tools like Azure Data Studio provide easy ways to search by table name, I find…
InSQL
Monitoring query performance is an essential aspect of proper database management. Poorly performing queries can produce a domino effect, affecting the overall health of your database server and severely degrading application user experience. Queries that result in many reads and writes to the hard disk and that use excessive amounts of CPU time and memory…
InSQL
When working with a SQL Server database, I often find it helpful to have a SQL query to hand that can be executed to tell me how many rows exist within each database table. This can be useful in scenarios where records are being inserted into lots of tables and you need to check that…
InSQL
Have you ever installed an instance of SQL Server onto a new workstation or server and subsequently realised that you forgot to rename the machine first? In these cases, you’ll likely have installed both SQL Server and SSMS (SQL Server Management Studio). After launching SSMS you happen to notice that the ‘Server name’ field is…
InSQL
Whenever I’m analysing the performance of a SQL Server database, I often find myself needing to retrieve a list of all indexes for review. Missing or unsuitable indexes are a leading cause of SQL Server slowdowns, so it can be very useful to view the existing indexes to get an idea of how heavily indexed…
SQL injection is a common attack vector that remains one of the most prevalent security risks for applications today. One of the reasons SQL injection attacks are so pervasive is the fact that injection vulnerabilities are very easy for attackers to discover and exploit, sometimes with devastating consequences. On the other hand, mitigating SQL injection…
InSQL
Sometimes when working with a SQL Server database, you need to update a specific table row or insert a new row if the one you were trying to update isn’t already there. This logic is known as an ‘upsert’ operation i.e. either update or insert a row depending on whether it currently exists. In this…