In the article, a CASE statement in SQL, we explored one of the important logical expressions – the Case statement in SQL Server to return the values based on the specified condition. Today, we will talk about another useful logical Choose() function in SQL Server 2012 onwards and its comparison with the Case statement.
Read more »Database development
Exploring actions and tasks in the SQLPackage Utility
June 4, 2020In this article, I am going to explain in detail about actions and tasks in the SQLPackage Utility. In my previous article, I have explained the overview of the SQLPackage utility. The SQLPackage utility is a command-line utility tool provided by Microsoft to automate SQL Server database deployments. Since this utility is cross-platform, you can easily install it on any operating system of your choice. SQLPackage actions are the types of functions that we can achieve with this utility. You can install this utility directly on any production server and it can be used as is. You can find more information about this utility and SQLPackage actions from the official documentation from Microsoft.
Read more »Security Testing SQL Logins with the PWDCOMPARE function
June 3, 2020In this article, we’ll look at using the built-in PWDCOMPARE function in SQL Server for security testing passwords. While this tool may seem like it exposes a weakness in Microsoft SQL Server because we can test for passwords, it should be of note that an attacker could do the same attack by attempting to login to our database server assuming the attacker was able to access a connection to it. Therefore, this function does not increase the risk of an attack on SQL Server but does help us identify possible weaknesses in our environment so that we can quickly mitigate these risks. In addition, we’ll also combine this with other related tools in SQL Server to help us with logins.
Read more »Lever T-SQL for Pinpoint Control of ORDER BY in a Stored Procedure
June 1, 2020Introduction
The T-SQL ORDER BY clause sorts SQL Server SELECT statement result sets, and it becomes important when we build stored procedures. Unfortunately, the syntax offers no flexible way to directly control the ORDER BY clause behavior with argument values. This means we don’t have an easy way to control the specific column or columns that the ORDER BY clause sorts. Additionally, SQL Server does not offer a flexible way to directly control the ascending or descending order of any ORDER BY clause column with argument values. Of course, we can certainly hard-code the ORDER BY clause in a stored procedure, but this approach becomes fixed in stone. We could try a dynamic SQL solution, involving a stored procedure code that dynamically builds and executes SQL Server statements inside a stored procedure. However, this technique becomes tricky, and it can lead to SQL injection attacks. Other techniques might rely on CASE statements, and their complexity can become overwhelming as the column count grows. This article spotlights a clean, efficient, pinpoint T-SQL stored procedure technique that directly sorts one, some, or all SELECT statement result set columns. The technique avoids dynamic SQL, and it operates directly in a stored procedure. The article also shows how to set the ascending or descending sort order of specific columns.
Read more »Explore the DATABASEPROPERTYEX() function for SQL Server databases
May 28, 2020In this article, we explore a SQL function to extract SQL database metadata using the DATABASEPROPERTYEX function.
Read more »Getting Started with the SQLPackage Utility
May 28, 2020In this article, I’m going to explain in detail about the SQLPackage utility that is provided by Microsoft in order to automate database deployments. In my previous article regarding Data-Tier Applications in SQL Server, I have mentioned how to create a DACPAC and a BACPAC file from an existing SQL Server Database. The underlying technology behind creating the DACPAC and the BACPAC files is the SQLPackage utility, which helps to create those files.
Read more »Impact of the Column order in SQL Server Composite Indexes
May 28, 2020In this article, we will explore the Composite Index SQL Server and the impact of key order on it. We will also view SQL Server update statistics to determine an optimized execution plan of the Compositive index.
Read more »Using tSQLt for Test-Driven Data Warehouse Development (TDWD)
May 21, 2020This is the second part of a conceptual article for data professionals and enthusiasts interested to work on a test-driven data warehouse development concept by using tSQLt an industry recognized SQL unit testing framework.
Read more »Import XML documents into SQL Server tables using SSIS packages
May 21, 2020This article guides you through importing XML documents into SQL tables using SSIS packages.
Read more »The JSON_QUERY() function to extract objects from JSON Data
May 19, 2020In this article, we will explore JSON_QUERY() functions in SQL Server to extract JSON objects and array from the JSON Data.
Read more »An Overview of the XML Task in SSIS Packages
May 18, 2020Introduction
We can use an SSIS package to perform various tasks such as data import, transform, and get output in various formats. Once we launch Visual Studio 2019 and create an integration services project, it shows you various tasks in the SSIS toolbox. In this article, we will explore the XML Task in the SSIS.
Read more »MySQL Create Table statement with examples
May 13, 2020In this article, I am going to explain the MySQL CREATE TABLE statement with examples. The following syntax contains basic statements to create a table in MySQL.
Read more »Lever T-SQL to dynamically define duplicate SQL Server database table rows
May 11, 2020Introduction
Lever T-SQL to handle duplicate rows in SQL Server database tables article highlighted T-SQL features that detect and handle duplicate SQL Server table rows. The techniques work well, but they rely on fixed duplicate row definitions. This article extends those techniques, showing how to define duplicate rows in a dynamic way.
Read more »The Concept of Test-Driven Data Warehouse Development (TDWD) with tSQLt
May 7, 2020This is a conceptual article consisting of two parts with enough supported material for any data professional or enthusiast with databases or data warehouse development background willing to go a step ahead by using an industry-recognized SQL unit testing framework called tSQLt.
Read more »Memory-Optimized Table Variables in SQL Server
May 6, 2020This article will cover the usage details and performance advantages of the memory-optimized table variables.
Read more »Build an ASP.NET app with Azure SQL Database
May 6, 2020In this article, you will learn about Azure SQL Database and its uses. Then the article splits into two sets of tutorials. The first part will show you how to create a single database in Azure SQL Database. The second tutorial will show you how to build an ASP.NET app in Azure SQL Database.
Read more »Extract scalar values from JSON data using JSON_VALUE()
May 5, 2020In this article, we will explore JSON_VALUE() function in SQL Server to extract scalar values from JSON data.
Read more »Modifying JSON data using JSON_MODIFY() in SQL Server
May 4, 2020This article explores JSON_MODIFY() function to modify JSON Data in the SQL Server.
Read more »An introduction to Data-Tier applications in SQL Server
April 29, 2020In this article, I’m going to introduce the data-tier applications in SQL Server. As the official documentation from Microsoft says – “Data-tier applications in SQL Server are a logical entity that can be used to develop and manage most of the SQL Server objects like tables, views, stored procedures, functions etc. as a self-contained package“. Essentially, what that means is it is a component of SQL Server, using which we can develop, build, test and deploy databases for SQL Server just like we can do for any other web or desktop applications.
Read more »Lever T-SQL to handle duplicate rows in SQL Server database tables
April 24, 2020Duplicate rows in a SQL Server database table can become a problem. We will see how we can find and handle those duplicate rows using T-SQL in this article.
Read more »Pagination in SQL Server
April 14, 2020Pagination is a process that is used to divide a large data into smaller discrete pages, and this process is also known as paging. Pagination is commonly used by web applications and can be seen on Google. When we search for something on Google, it shows the results on the separated page; this is the main idea of the pagination.
Read more »How to update the T-SQL Toolbox database
April 6, 2020Introduction
In an earlier article, Solve Time Zone, GMT, and UTC problems using the T-SQL Toolbox database, I described T-SQL Toolbox, a free, open-source SQL Server database that handles time zone, date, and time calculations in a clean and efficient way. Available here at the CodePlex Archive, and here at GitLab, T-SQL Toolbox relies on time zone and time zone adjustment data in its two tables for many of its own calculations. However, T-SQL Toolbox does not update that data. I built primitive C-Sharp and VB.net applications that extract the latest time zone and time zone adjustment data from the Windows registry, and I discussed those applications in that earlier SQL Shack article. In the article, I explained that we can build SQL Server UPDATE statements with this extracted data, and then update the T-SQL Toolbox tables. This article describes a better approach and a better solution.
Read more »Table-Valued Parameters in SQL Server
April 6, 2020Table-Valued Parameters aka TVPs are commonly used to pass a table as a parameter into stored procedures or functions. They are helpful in a way, we can use a table as an input to these routines and we can get rid of dealing more complex steps to achieve this process.
Read more »How to compare two SQL databases from Visual Studio
April 3, 2020Visual Studio is an application that is used by many developers and it has different kinds of features that can facilitate the developer’s work. Among these features, Visual Studio offers users the feature to compare two SQL databases via its Schema compare feature.
Read more »Dynamic Pivot Tables in SQL Server
April 2, 2020In this article, I am going to explain how we can create a dynamic pivot table in SQL Server. Pivot tables are a piece of summarized information that is generated from a large underlying dataset. It is generally used to report on specific dimensions from the vast datasets. Essentially, the user can convert rows into columns. This gives the users the ability to transpose columns from a SQL Server table easily and create reports as per the requirements.
Read more »