MSSQL Query Blog

Changing Collation of All Columns in SQL Server

Hello everyone. In this article, I will try to give information about changing the collation of all columns in SQL Server. In SQL Server, in some cases, when you change the Collation of the database, the Collation may not change in the columns and you may want to change the...

All Uses of DROP IF EXISTS in SQL Server

Hello everyone. In this article, I will give information about all DROP IF EXISTS usages in SQL Server. In SQL Server you may need to use DROP IF EXISTS in some cases. You can easily do this using the code below. Note: The commands below work on SQL Server 2016...

Cleaning Right and Left Spaces in SQL Server

Hello everyone. In this article, I will give information about cleaning left and right spaces in SQL Server. In SQL Server you may want to clear left and right spaces in some cases. You can easily do this using the code below. You can use the code below to clear...

Analyzing ½ in SQL Server Mathematically

Hello everyone. In this article, we will analyze ½, that is, a part 2, expression in SQL Server mathematically. In SQL Server, you may come across such questions in interviews or while writing a query. This is a small question. However, it’s also an interesting question. Many people immediately answer...

Creating a Recursive Menu in SQL Server

Hello everyone. In this article, I will try to give information about creating a Recursive Menu in SQL Server. You can create simple or advanced nested menus in SQL Server. First, let’s create a table called “Menu”. CREATE TABLE Menu ( MenuID INT PRIMARY KEY ,MenuName NVARCHAR(50) ,ParentMenuID INT NULL...

Formatting an IBAN Number in SQL Server

Hello everyone. In this article, I will give information about formatting an IBAN number in SQL Server. In SQL Server, in some cases, you may want to format the IBAN number. You can easily do this using the code below. DECLARE @iban VARCHAR(50) = ‘TR320010009999901234567890’; SELECT CONCAT(SUBSTRING(@iban, 1, 2), ‘...

Converting Hijri Date to Gregorian Date in SQL Server

Hello everyone. In this article, I will give information about converting Hijri date to Gregorian date in SQL Server. In SQL Server, in some cases, you may want to convert the Hijri date to the Gregorian date. You can easily do this using the code below. SELECT CONVERT(DATETIME, value, 131)...

Don`t copy text!