SQL Code

SQL Query Processing

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


SQL COALESCE Function

The goal of this demonstration is to use the COALESCE function to find the annual salary of each employee. The first section of code is creating a table…


The Output Clause

When you run Data Manipulation Language (DML) statements such as an INSERT, UPDATE, or DELETE, in most cases you will receive a message similar to…


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 IDENTITY columns in a table. First of all, an IDENTITY field is very similar to an…


Using the INSERT statement

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


Data Manipulation Language (DML)

For this demonstration on Data Manipulation Languare (DML) statements we will create a table named dbo.TestTable with four columns. Then we will be using the INSERT statement to add…


SQL Join Types

When pulling data from more than one table you will need to JOIN the tables together. The JOIN types will determine what records will be returned in the…


DML Triggers

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