SQL Server

Convert existing table to temporal table

In the previous post, we have discussed the temporal table, which is introduced in SQL Server 2016 to store the time varying data (current data and the data change history along with the time period). There, we have also learnt how we can create a temporal table from scratch. In this post “Convert existing table to temporal

Convert existing table to temporal table Read More »

Temporal Table in SQL Server

In this post we are going to discuss “Temporal Table”, a new feature introduced in SQL Server 2016. Lets start this post “Temporal Table in SQL Server” with the definition of temporal table. Temporal Table facilitates inbuilt support for data change tracing along with the time period in a table. It holds the current as well as historical data to determine the

Temporal Table in SQL Server Read More »

SELECT Statement

Now that we have been familiar with Create, Alter and Drop – Database and Table, it is time to be familiar with T-SQL statements. Let’s start this chapter with the definition of T-SQL followed by a detailed discussion on T-SQL’s SELECT statement. Transact SQL (T-SQL) Transact SQL (T-SQL) is a proprietary extension of SQL (structured Query Language) by Microsoft

SELECT Statement Read More »

Get hierarchical data in order

In this post, we are going to learn how we can get hierarchical data in order. We are dealing with a user defined hierarchical data which can have “n” number of siblings and their siblings can also have “n” number of siblings in turn. For demo purpose, we have a Product_Master table, in which a product can be marked as a parent

Get hierarchical data in order Read More »

Create, Alter and Drop – Database and Table

Now that you are familiar with database concepts and SQL Server Management Studio, it is time to begin our journey with T-SQL programming. In my opinion, to shine as a good T-SQL programmer, one must have a good understanding of T-SQL concepts and its capability. In this chapter “Create, Alter and Drop – Database and Table”, we are

Create, Alter and Drop – Database and Table Read More »

Exploring SQL Server Management Studio

In this SQL Server Tutorial, we have gone through DBMS, RDBMS and SQL Server, Table Relationships, Data Integrity, Types of keys and Database normalization chapters. Now that we have a good understanding of database concepts, it is time to put our feet in T-SQL. Before we begin our journey with T-SQL (MS SQL Server programming language) we need to be familiar with SQL Server Management Studio, also

Exploring SQL Server Management Studio Read More »

Generate serial number for each consecutive set of numbers

In this post, we are going to generate serial number for each consecutive set of numbers in a given column. We have a table tbl_Donation with columns EmpId and DonationYear. For each consecutive set of years of each employee, we need to generate serial numbers. If employee “X” donated in 2006, 2007 and 2008 years consecutively and

Generate serial number for each consecutive set of numbers Read More »

Database normalization

In previous chapter, “Types of keys“, we had a good discussion on keys and their types in SQL Server. In this chapter “Database normalization”, we are going to discuss database normalization process and normal forms. Lets start our discussion with definition of Normalization. Normalization Normalization is a process of minimizing redundant data from database by decomposing the columns of a table

Database normalization Read More »

CHAR, NCHAR, VARCHAR and NVARCHAR default length

What is the default length of CHAR, NCHAR, VARCHAR and NVARCHAR when we don’t specify their length in their length argument? If we omit the size of CHAR, NCHAR, VARCHAR and NVARCHAR, how they behave? In this post “CHAR, NCHAR, VARCHAR and NVARCHAR default length”, we are going to discuss the default length of CHAR, NCHAR, VARCHAR and NVARCHAR data types,

CHAR, NCHAR, VARCHAR and NVARCHAR default length Read More »