Database Development – All Posts

This is a list of all the articles posted on this blog about SQL Server database development.

Hijri Date in SQL Server – with Islamic Month Name

This article focuses on converting the Gregorian date into an Islamic date along with Islamic month name in textual format. In SQL Server there are two methods to convert the Gregorian date to Islamic date, however, for Islamic month name we need to depend on our own code.   Either you can write a function…

Multiple Ways to Find Missing Serial Numbers in SQL

In my previous blogs, I had mentioned that there will be many ways to solve a problem. The below is one more example.  Often, in some tables where identity column exists, will have some missing sequences due to some data fixes. Or we may have some sequential numbers or numeric ranges in a table from…

Logical vs Physical Computed Columns

Many people have asked me about the difference between using and not using ‘PERSISTED’ in a computed column; and how do we know whether the column values are being stored logically or physically.  I would like to share the answer to these questions and some more information here. Let me start the with the definitions…

Adding Multiple Columns With Default Value

Almost a decade before, I came across a requirement where I needed to add multiple columns in a table with default value. It took a while on that time to figure it out. I found it in my old SQL Projects repository and thought to share it with you. — Creating a table and adding…

Creating Linked Server for PostgreSQL in MSSQL

Creating a linked server in Microsoft SQL Server to connect PostgreSQL 1) Download the PostgreSQL Unicode (x64) driver to support ODBC. 2) Go to ODBC Data Source Administrator in your machine and create the system DSN.3) Go to SQL Server Management Studio and execute the below command in a new query window. EXEC master.dbo.sp_addlinkedserver @server =…

SQL Server – Insert Data From Linked Server Table

In a situation where Servers are linked, it is possible to retrieve data from a table in one server to a table on the other server. Following is the method to carry this out: SELECT @@SERVERNAME This will return the server’s name to which you are currently connected to. SELECT * FROM [bngstagedb]. testDB.dbo.temp2 WITH…

Creating a table and a view with the select statement.

In this article, you’ll learn how to create a view and table based on a select statement.-~ To create a viewCREATE VIEW Emp_View ASSELECT Ename, DName FROM EmpINNER JOIN Dept ON Emp.DeptNo = Dept.DeptNo; -~ To create a tableCREATE TABLE EmpDept AS SELECT Ename, DName FROM EmpINNER JOIN Dept ON Emp.DeptNo = Dept.DeptNo; Can we create a table…

Reserved Keywords As Columns In SQL Server

In this post, we’re going to talk about using reserved keywords as column names. This is very similar to the previous “IMPALA – Reserved Keywords As Columns” article, but we will see how it can be implemented in SQL Server this time. It is not best practice to use the reserved keywords for tables and…

SQL – Searching Unicode Strings

Is it possible to search strings in columns assigned with the Unicode datatype in the same way that we search strings in non-Unicode columns?No, it’s slightly different approach.Let’s look at what Unicode and non-Unicode datatypes are before we get started with the exercise.Despite the fact that Unicode and non-Unicode work alike, UNICODE is a standard for…

SQL – Searching the column that has multiple lines

When typing information into a text/memo field on a webpage, the end-user sometimes press the “Enter” button. This resulted the text/information being split into several lines, which were then saved in databases. There will be some other reasons too, for multiple lines in a column. The information seems to be in a single line when…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s