Writing SQL


What is a Schema?

This is one of those terms in the IT world that actually has several definitions depending on who you ask. For a developer, a schema is usually meant as the structure or the definition of an object. For SQL Server as an example, the schema would be how a table…


SQL Four-Part Names

As part of the T-SQL naming convention in SQL Server every object (Table, View, etc…) has a four part name used to reference that object. For SQL Servers prior to 2005 the four part name used the format Server.Database.Owner.Object For SQL Server 2005 and later the naming convention changed to the…


SQL Categories

The Transact-SQL language is split up into four SQL Categories Data Manipulation Language (DML) – These statements allow you to manipulate the data within your tables. Technically, the SELECT statement is in its own category DQL (Data Querying Language). However, most people place it into the DML category. Data Control Language…


Data Type Conversion

When combining Data Types it is important to note that there is a data type precedence used to determine how they are converted and combined. Data types with a lower precedence are implicitly converted to the data type with the higher precedence. If a data type of a higher precedence…


Date and Time Data Types

In this demonstration, we will see how to work with the various DateTime data types within in SQL Server. Prior to SQL Server 2008 we only had the DATETIME and SMALLDATETIME data types. Now we have four additional data types to help be more efficient in storing our data. We…


Integer Data Types

Here are some examples of the integer data types. When deciding on an integer for a column, variable, parameter or expression it is a wise choice to choose the most efficient data type based off of size and usage. TINY INTEGER – The tiny integer data type allows for whole numbers…


Character Data Types

Regular Character Data Types – Both the char and varchar data types are considered regular or non-Unicode character data types where each alphanumeric character uses only one byte of data. This is in contrast to the Unicode character data types (nchar and nvarchar) that uses two bytes of data for each alphanumeric character….


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 with five columns to hold sample data.Next we use an INSERT statement to add 4 rows of data to our demonstration table. Now that we…


What is SQL?

I get this question a lot, which is understandable as there are several meanings depending on the context the question is being asked. The quick response is that it is a language and a server. Let’s start on the language side. SQL stands for Structured Query Language and is used…