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 »

Due to the increased demand on my time to complete the next beta of Database Health Monitor, I have created an IndieGoGo campaign to help fund the next beta version. If you haven’t heard of IndieGoGo, its sort of like KickStarter, it is a crowd funding site. Please give something if you can to help me fund the next beta …

Help Support The Database Health Project 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 »

After being inspired by reading about Brent Ozar’s Epic Life Quest, I created my own Epic Life Quest list, and for level 1 one of my goals was to run in a 5K race. I completed that goal today, I finished a 5k race, I wasn’t fast, but I did complete it. My time was  37 minutes and 57 seconds. …

Epic Life Quest Level 1 – partially completed today. Read more »

A cursor is a tool in SQL Server that allows a user to traverse through the rows of a result set one row at a time. This can be useful for performing operations on each row of the result set individually, such as updating or deleting specific rows. Cursors are created using the DECLARE CURSOR statement, and are associated with …

Simple Introduction to TSQL Cursors Read more »

On Thursday March 19th at 9:00am (pacific time), we will be hosting another free training provided by Aaron Buma and I to prepare for the Microsoft 70-461 SQL Queries exam. This week we will be a three part session on functions. This is provided free of charge to give back to the SQL community. We have been getting quite a following so …

Next Weekly Training: Functions (Logical Functions, Time Functions, and UDFs) Read more »

Here is the outline: Using Cursors Using String Functions Here is the link to the Google On Air Broadcast where you can watch for free. https://plus.google.com/events/ci8jms67qttuteegimrf4sj70sk After the presentation, I will update this page with a link to the YouTube video. This session will be about 90 minutes, Aaron Buma will present about half and I will present the other …

Today’s Live Training: Using Cursors and TSQL String Functions 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 »