Welcome to Part 4 of our ongoing series on T-SQL programming constructs. So far, we’ve discussed variables, conditional IF statements, loops, CASE expressions, and covered essential concepts like error handling and transaction management. Now, we turn to Common Table Expressions (CTEs)—a powerful feature in T-SQL that can simplify complex queries and enable recursion.
Category: SQL Developer
Natively Compiled Stored Procedures with in-memory OLTP in SQL Server
Modern applications often demand lightning-fast performance from their databases, whether they’re handling large transactional workloads or complex analytical queries. SQL Server’s in-memory OLTP feature addresses these needs by using memory-optimized tables and natively compiled stored procedures to boost throughput and reduce latency. This post provides an overview of natively compiled stored procedures, how to create them, and best practices for performance monitoring and maintenance.
Five Helpful Queries for SQL Server DBAs
As a SQL Server DBA, having the right set of queries can significantly streamline your workflow, enhance monitoring, and aid in troubleshooting. This post shares five essential queries that address common administrative tasks, each accompanied by a detailed explanation to help you understand their purpose, interpret the results, and take appropriate action.
SQL Server 2025 Teaser – Exploring the Innovations in SQL Server 2025
SQL Server 2025 is a significant milestone in database technology. Its advanced features empower developers, streamline operations, and support modern application scenarios. Find out why SQL Server 2025 will be such an exciting release!
Using sp_getapplock to Prevent Concurrent Execution of Stored Procedures in SQL Server
In multi-user database environments, ensuring the integrity and consistency of data is essential. One common challenge is preventing multiple instances of the same stored procedure from executing at the same time, which can lead to data conflicts, race conditions, and unpredictable results. To address this, SQL Server provides a powerful tool called sp_getapplock. This post explains what sp_getapplock is, what you are actually locking when you use it, how to implement it to prevent concurrent executions of a stored procedure, and the difference between transaction-level and session-level locks.
Exploring Programming Constructs in T-SQL – Part 3: Error Handling and Transaction Management
Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we’ll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY…CATCH Blocks and Transaction Management.
Archiving Old Transactions in SQL Server Using PowerShell
Archiving old or obsolete data is an effective strategy to maintain optimal performance. In this post, we’ll explore how to archive old transactions from a SQL Server database using PowerShell. We’ll walk through creating the necessary database and tables, populating them with sample data, executing a PowerShell script to automate the archiving process, and verifying the results.
Exploring Programming Constructs in T-SQL – Part 2: Loops and CASE Expressions
Welcome back to our series on programming constructs in T-SQL! In Part 1 of this series, we explored the fundamentals of variables and conditional IF statements, laying the groundwork for dynamic and efficient SQL scripting. In this second installment, we’ll delve deeper into T-SQL by examining two more powerful constructs: Loops (specifically the WHILE loop) and CASE Expressions. Understanding these constructs will enable you to handle repetitive tasks and implement conditional logic directly within your SQL queries, further enhancing the flexibility and capability of your scripts.
Testing Always Encrypted with Parameterized Queries in SQL Server
It’s more important than ever to be vigilant in protecting and securing our data. Always Encrypted is a feature in SQL Server designed to protect sensitive data, such as Social Security numbers or credit card information. In this guide, we’ll focus on testing Always Encrypted using parameterized queries to ensure data remains secure during common operations like searching, inserting, and updating.
Avoiding Recompiles in Dynamic SQL: Best Practices for SQL Server
Dynamic SQL is a powerful feature in SQL Server that allows you to build and execute SQL statements on the fly. It’s especially useful when you need flexibility in your queries based on varying conditions. However, a common issue with dynamic SQL is that it can lead to frequent recompilations of execution plans, which can hurt performance. In this post, I’ll explain why this happens, how you can avoid unnecessary recompiles, and provide scripts you can use to test these concepts yourself.