SQL Code

SQL Four Part Names

As part of the T-SQL naming convention in SQL Server every object (Table, View, Stored Procedure, etc…) has a four part name used to reference…


SQL Query Processing

The post will describe how a SQL Server will PROCESS a query. The first time through running an Ad Hoc query, SQL Server will go…


SQL COALESCE Function

So I was teaching SQL Functions today and came to the section on working with the COALESCE function and decided to share my example for…


The Output Clause

When you run DML statements such as an INSERT, UPDATE, or DELETE in most cases you will receive a message similar to the one below….


Delete vs Truncate vs Drop

One of the questions I get frequently is what is the difference between using DELETE versus using TRUNCATE versus using DROP when working with data…


IDENTITY Columns

In this demonstration we will be showing how to use an IDENTITY field in a table. First of all, an IDENTITY field is very similar…


Using the INSERT statement

For this demonstration we will use the HR.Employees table that we created in the Table Constraints post. We will begin with just a simple INSERT…


Data Manipulation Language

For this demonstration we will create a table named dbo.TestTable with four columns. Then we will be using the INSERT statement to add records to the table, the UPDATE…


SQL Join Types

When pulling data from more than one table you will need to JOIN the tables together. Based off the type of JOIN will determine what…


DML Triggers

There are two types of DML Triggers that can be written for each INSERT, UPDATE, or DELETE statements. Either AFTER triggers or INSTEAD OF triggers….


SQL Table Constraints

When creating tables you would want to use constraints to enforce data integrity. Here is a list of the constraints and why they are used…