Dynamic SQL Execution in SQL Server

Dynamic SQL is a statement constructed and executed at runtime, usually containing dynamically generated SQL string parts, input parameters, or both.

Various methods are available to construct and run dynamically generated SQL commands. The current article is going to explore them, define their positive and negative aspects, and demonstrate practical approaches to optimize queries in some frequent scenarios.

We use two ways to execute dynamic SQL: EXEC command and sp_executesql stored procedure.

CodingSight - Dynamic SQL Execution in SQL Server
Read More

Storing Binary Data Types in SQL Server

Introduction

Daily work rarely requires storing binary data directly to database columns. However, it is very useful in some cases.

Contrary to popular opinion, byte arrays can help with significantly more than just storing large binary objects (documents, multimedia, etc.). Also, they can be used to store hash values and sample data for faster searching/high-level analysis. Or, they might contain bytes that are in ON/OFF states in some electronic relay. As soon as we start to think about hardware data stored in databases, applications become more apparent.

CodingSight - Storing Binary Data Types in SQL Server
Read More

How to Use Array Functionality in SQL Server?

Have you ever been asked about creating arrays in SQL Server? Processing an array of values inside a procedure/ function in SQL is a common requirement. The question arises quite often, especially if you deal with Oracle specialists because Oracle has arrays. But the thing is, SQL Server does not have this.

Still, what if we need this functionality in the SQL Server environment? Fortunately, there are ways to resolve the issue. In this article, I am going to explain the most efficient alternatives to array in SQL Server.

CodingSight - How to Use Array Functionality in SQL Server
Read More