Skip Navigation

SQL Server Cheat Sheet

The SQL Server cheat sheet is a one-page A4 printable document, designed to provide a quick reference for SQL Server. A description of what is on the cheat sheet follows, or if you are impatient, you can go straight to the full size SQL Server cheat sheet.

It's been a while since my last cheat sheet release. But what could be better than to get the ball rolling again with the most requested cheat sheet not yet created (until now) - SQL Server. Microsoft's database engine is the source of many arguments between developers, but whether or not you believe another database to be superior, SQL Server is undoubtably powerful and includes some great management tools (Enterprise Manager, Query Analyser and the more recent SQL Server Management Studio) missing from comparable technologies.

Data Types and Conversion

Thumbnail highlighting Data Types and Conversion section. SQL Server supports a large variety of data types and good database design relies in part on using the right data type for the right column. This section lists the data types available in groups. I've also included the syntax for the CAST and CONVERT functions here for convenience.

Functions

Thumbnail highlighting Functions sections. SQL Server has a large array of built in functions of varying use. This section includes string, date, mathematical, grouping, ranking and table functions. Alongside the date functions block there is also a run down of the different "dateparts" - the characters used in date functions to denote different periods (day, week, month etc).

Creation

Thumbnail highlighting Creation section. Finally (short description for this cheat sheet!), the third part of the cheat sheet contains sample code for the creation of stored procedures, views, triggers, indexes and functions (the last of which I don't make nearly enough use of).

Download

The cheat sheet is available in two formats, PNG and PDF:

And finally, if you like the cheat sheets, and want to say thanks, please consider buying me something from my Amazon Wishlist. Thankyou very much to those who have already hunted it down and sent me something nice - I'm very grateful!

39 comments

Thanks for the new sheet! You're doing such a great job!!!
Your site is very well done.
All Cheat Sheets are very good.
Thanks,
Pinal
Thanks.

You have posted many, many useful cheat sheets. Thanks
when will you stop cheating?

seriously, you're doing a great job. thanks! :)
seo training
India #5: July 29, 2007
useful clean sheet, doing a good job
Nice! Thanks for sharing.
You should stop cheating :)
A MYSQL cheat-sheet would be more useful. No one except worthless micro$oft fanboys care about MSSQL.
jrgpmaster@gmail.com: Ummm. There is a MySQL cheat sheet.

Has it occurred to you that idiot comments like yours are one of the reasons that Open Source software has a hard time being taken seriously as an alternative to mature traditional software like SQL Server?

Anyone that knows me knows I am about as far from a Microsoft fanboy as you can get. And I still think SQL Server is awesome when coupled with PHP and run well. Especially on large scale sites.

Perhaps you should wait a few years (at least until you're in big boy pants) before joining in another discussion?
To everyone else: Thanks :)
 United Kingdom #11: August 21, 2007
Just recommended the cheat sheet to everyone at work.

Good work!
Hi, just discovered your fabulous site yesterday. Just wanted to say many thanks for your great work you've put in the cheat sheets, those are realy great! Wanted to take a peek on the MS SQL sheet but I can't download it... Broken link? Anyway, realy great job! I like this fresh lay out, previews designs were nice too, but this one is the best one! Keep on the great work, thanks! I'll have to spend a couple of hours to read the articles, look sgreat!
Sorry Gov - an .htaccess change broke the SQL links. All fixed now. Glad you like them, even when they're hiding :)
Great work! I have been looking for something like this.
The concept of cheat sheets is great, especially for people like me who keep on forgetting the essentials of a software and spend hours going throught the help files.

:)

Keep up the good work. and thanks to Ben Hunt for putting up a link on his website www.webdesignfromscratch.com through which I came here.
Gordon K
United States #16: October 25, 2007
Many thanks for all your contributions to the developer community!

One question about the SQL cheat sheet: When I click the PDF link, I only get the first page. I'd love to get the others as well! (Actually, I tried the MySQL sheet with the same result - only the first page comes up)
Hi Gordon. The cheat sheets are single-page references. You're not missing anything - it's just the one sheet :)
Simon Millar
Australia #18: December 4, 2007
Great site - what a brilliant idea! Would also love to see a SQL Server cheat sheet aimed at more at DBA's than Coders (CREATE LOGIN syntax, FILEGROUPS, DMV's etc) - maybe you've just inspired me to make my own! Don't forget the separate DATE and TIME types coming with SQL Server 2008 (joy)!
thanks a lot. it really helped me and is helping me everyday. I would like to get more on C# and asp.net.
Great cheat sheet.

There is a misspelling of nchav - should be nchar in the PDF.

Thanks for the work.
Wauw... great work!
This cheat sheet has helped me tremendously. Thanks!
Okay, I have to admit that it's really amazing sometimes that what a simple idea could do to the world.

I am even believing now these cheat sheets that you have created contribute to the webdev community no less than those O'Reilly geeks....
Anandan
Unknown #23: January 28, 2008
Thanks a many, Keep up this good job, never mind if hits goes up after me referring to my friends and well wishers....Danaks
Thank you! Posted on my cubicle walls for my cheating pleasure!
Chloe
Unknown #25: February 14, 2008
Cheat sheets can never go a-miss.
I also highly recommend for those linux boys out there to print of and get use to vim with a good quality cheat sheet.
The vim is my fav editor and with it being so integrated / easy to change with the linux cli, using the mysql / pgsql cli comes naturally..
Cheat sheets for all !!
baliwebdesigner
Australia #26: February 18, 2008
thank you :) appreciate this much
Can't wait to see what you come up with next!
You own dude!
Thanks for the work! I will print it and post in my wall :)
Anonymous
United States #29: March 21, 2008
these cheat sheets are amazing man. keep 'em coming
Daniele
Unknown #30: April 17, 2008
I appreciate the sheets. I had a bit of trouble finding the one I need, but the MSSQL sheet will make life easier for me.
Thank you.
Samir Sood
India #31: April 17, 2008
Yes, all sheets are really useful.Go ahead with new sheets.
Hari Haran
harimail2000@rediffmail.com #32: April 29, 2008
Hi Dave,

I have all your cheat sheets in my desk always. I like to say my heartfelt thanks for your smart thinking and the effort you taken for the same to help people like me.

Is is possible to have a cheat sheet for .net (especially for me I need for 2003, framework, C#, VB and ado.net).

If you have in your collection, can you able to share with me?

Thanks in advance.
Hari Haran.R

Yours,
one of your site user

Good stuff. Remember when we were punished in school for having these? Cheat sheets rule, thanks.
Its a really very useful article, most of your cheat sheets are on my desk.

Most of the time I use the CSS, SQL, Regular Expressions, Javascript,

Please post the Some .NET Cheat Sheet, if you have any.

I would like to share one provided by microsoft through my blog
http://www.dotnetglobe.com/2008/05/net-framework-35-namespaces-poster.html


I have corrected the typo in the cheat sheet - "nchav" is now "nchar".
Tomse
Denmark #36: June 30, 2008
Is it possible to have some kind of version/date numbering in the sheets ?

Then you can always compare with your local version of the sheet.
Roberto
Italy #37: August 5, 2008
Hei guys...
take attention because in MsSQL the UTC Date function is GETUTCDATE and not GETUCDATE!!
I think this is only a typing error.

Good Job!!!
Well spotted, Roberto, and thanks for the heads up. I've fixed the typo.
Great job, especially love the CSS cheat sheet, and the SQL Server one is pretty cool too. Can I point out a bug on the Sql Server sheet? Shouldn't that first panel be called "Data Types" or somesuch?

Keep up the good work!

Post Your Comment

· Comments with keywords instead of a name have their URLs removed.
· Your email address will not be displayed or shared.

Live Comment Preview

 United States #40: 1 minute ago