>>> Try our online JOIN Types Course Today! As I have been working on the SQL Server JOIN Types poster, I have received several questions around the difference between a CROSS JOIN, and a FULL OUTER JOIN. After looking at the Venn diagrams for the two, they are both shown as the same, however they are not the same by …

FULL OUTER JOIN vs CROSS JOIN Read more »

Here is a quick video training on how to use the T-SQL DATEPART function on SQL Server. This was originally part of my free SQL query training for the 70-461 certification exam. And here is the sample code to go with the video tutorial: See Also Additional Training on my YouTube Channel Free SQL Query Training 70-461 exam preparation

Here is a quick video tutorial on how to use the T-SQL GetDate function on SQL Server 2012, SQL Server 2014 or newer. This was originally part of my free SQL query training for the 70-461 certification exam. Here is the sample code that goes with the video. See Also Additional Training on my YouTube Channel Free SQL Query Training 70-461 …

Using the TSQL GetDate Function Read more »

You can use the TSQL DATEPART function to extract individual parts of the date from a date or time item. For instance: Will return the following output:   The second parameter is the date/time element which can be any of these types: time, date, smalldatetime, datetime, datetime2, or datetimeoffset.   Lets take a look at the possible options for the first …

The TSQL DATEPART Function Read more »

Try our JOIN types course today! So many times I have been asked for help with a query, where the question really comes down to the understanding of the difference between INNER and LEFT or RIGHT JOINs. I created this poster a few years ago and I keep it posted on the wall at the office. This way when I …

SQL Server Join Types Poster (Version 2) Read more »

First lets take a look at two queries using CURSORS, the first one will use the FORWARD_ONLY type cursor, and the second will use the FAST_FORWARD type cursor. These two types sound very similar, but perform quite differently. Now for the FAST_FORWARD CURSOR example. Notice only one line has changed, that’s the line that says “SET @PeoplePhoneCursor = CURSOR FAST_FORWARD …

Simple Cursor Example : FORWARD_ONLY vs FAST FORWARD Read more »

In SQL Server the cursor is a tool that is used to iterate over a result set, or to loop through each row of a result set one row at a time. It may not be the best way to work with a set of data, but if you need to loop row by agonizing row (RBAR) in a T-SQL …

T-SQL: A Listing Databases Example Using a Cursor Read more »

Using the GO commend in TSQL to run a batch of code multiple times is something that I commonly do in demo’s and training’s.  What amazes me is how many people after the training will tell me that they didn’t know about using the GO command to run a statement multiple times. Here’s how it works. First lets create a table, …

Executing a TSQL batch multiple times using GO Read more »

Earlier in the week I added a blog entry on using the OUTPUT Clause on INSERT Statements, today I will expand it by exploring the use of the OUTPUT clause with UPDATE statements. Generally when you do an UPDATE statement you only get a row count returned, you don’t generally get a result set showing what was changed. With the OUTPUT clause …

TSQL OUTPUT Clause With UPDATE Statements Read more »