Introduction to Common Table Expressions (CTEs)
Common Table Expressions or CTE’s for short are used within SQL Server to simplify complex joins and subqueries, and to provide a means to query hierarchical data such as an organizational chart. In...
View ArticleNon Recursive CTEs Explained
Introduction to Non Recursive CTEs In this article we explore non recursive CTEs (Common Table Expressions). This is a broad class, and basically covers every form of CTEs except those that call...
View ArticleRecursive CTEs Explained
Recursive CTE’s In this article we explore recursive CTE’s (Common Table Expressions). Recursive CTEs are special in the sense they are allowed to reference themselves! Because of this special...
View ArticleHow Do You Calculate the End of the Month in SQL?
When working with SQL dates, sometimes you need to calculate the end of the month. Months are tricky! Some are 28 days, others 30 or 31, and now and then there’s a leap year! So, given a date, how do...
View ArticleUncommon SQL Server Data Types
In this article we’re going to go over a uncommon SQL server data types. These are those you won’t use every day, but you’ll want to know if you take the 70-461 exam. Even if you don’t plan on taking...
View ArticleCross Join Introduction – Create Row Combinations
A cross join is used when you wish to create combination of every row from two tables. All row combinations are included in the result; this is commonly called cross product join. A common use for a...
View ArticleIntroduction to SQL Server Data Modification Statements
In this article we’ll discover data modification statements used to modify data in SQL server using the INSERT, UPDATE, DELETE, and MERGE statement. The SELECT, INSERT, UPDATE, DELETE, and MERGE...
View ArticleIntroduction to the INSERT Statement using SQL Server
The INSERT statement is used to add rows to a SQL Server data table. In this article we’ll explore how to use the INSERT statement. We discuss some best practices, limitations, and wrap-up with...
View ArticleIntroduction to the UPDATE statement
The UPDATE statement is used to change data within columns of a SQL Server data table. In this article we’ll explore how to use the UPDATE statement. We discuss some best practices, limitations, and...
View ArticleIntroduction to the Delete Statement
The DELETE statement is used to remove rows from a SQL Server data table. In this article we’ll explore how to use the DELETE statement. We discuss some best practices, limitations, and wrap-up with...
View ArticleIntroduction to the Merge Statement
Introduction to the MERGE Statement and SQL Server Data Modification The MERGE statement is used to make changes in one table based on values matched from anther. It can be used to combine insert,...
View ArticleWhat is the Difference Between Merge and Update?
When modifying one table based on the contents of another it may be tempting to simply use the merge statement, but before you throw away all other forms of modifying data, I think it’s important for...
View ArticleSQL Puzzle: How to Rank Student Scores
In this puzzle, we’re going to work through a problem to identify the top and bottom 25 percent to rank student scores. Solving puzzles is a great way to learn SQL. Nothing beats practicing what...
View ArticleSQL Puzzle: How to Calculate Moving Averages
In this puzzle, we’re going to learn how to calculate moving averages by working through a hypothetical stock market example. Solving puzzles is a great way to learn SQL. Nothing beats practicing what...
View ArticleHow to Find a Gap in a Sequence using SQL SERVER
In this puzzle, we’re going to learn how to find a gap in a sequence using SQL Server. I was recently reviewing my bank statement and noticed they flagged the start of a missing check number with...
View ArticleHow to Create A Bar Chart Using SQL Server
In this puzzle, we’re going to learn how to create a bar chart using SQL Server. Sometimes it’s fun to see what you can do with the humble SELECT statement. Today I figured it would be fun to see if...
View ArticleWork with the AdventureWorks Bill of Materials using Subqueries
In this puzzle, we’re going to learn how to work with the AdventureWorks Bill of Materials table. Companies use a BOM (Bill of Materials) to itemize the products that are used or contained in another...
View ArticleReturn the first rows from your result.
In this video we’ll walk you though how to select top rows within a query. We’ll show you how to retrieve the top or bottom rows in the result. We’ll also show you how to use one sort to select the...
View ArticleHow do I use the Like Clause in SQL Server?
In this video we’ll walk you though how to use the LIKE clause. We’ll show you how to you can perform partial matches, such as being able to match all names beginning with “B” or ending in “Y.”...
View ArticleLearn how to Work Joins and Messy Data
In this puzzle, we’re going to learn how to join dirty data using SQL Server. Many times you’re forced to use someone else’s data. Since it is their system and data, not yours, you can’t always fix...
View Article