Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It was pointed out to me yesterday that I need to get a book on SQL and learn about it properly. That is probably a fair assessment; I'm a functioning SQL programmer who can in general extract from the database the information that is needed, but as soon as extracting the data needs more than a couple of joins and a where clause the query that I come up with is probably not as good as it could be.

Previously I was working at an Oracle shop where there were a few very good SQL programmers who would generally design the more complex queries and would be on hand to answer questions, but now I'm at a SQL Server shop where no one really has much of a clue about SQL and so I feel like I need to get my skills up.

What I'm looking for is a book that is fairly short and very practical that I can work through in the evenings with a series of difficult SQL problems and then well explained solutions along with a few pieces of sage advice that is aimed at a programmer who can "do SQL" who wants to become more of a "SQL programmer". I appreciate that many things about SQL are platform dependent, so since I'm currently in a SQL Server shop then my preference would be for a book aimed at TSQL.

Any suggestions?

share|improve this question

closed as off-topic by durron597, gnat, GlenH7, Ixrec, Snowman Apr 21 '15 at 4:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – durron597, gnat, GlenH7, Ixrec, Snowman
If this question can be reworded to fit the rules in the help center, please edit the question.

You make it sound like SQL Server folks are not real programmers. Just because something is not a royal pain in the arse ... – Job Apr 24 '11 at 3:25
That is not what I'm saying at all. Actually I think I'm saying the exact opposite. IMO SQL programming, or if you prefer learning to write SQL correctly, is a specialism that is all to often ignored by professional programmers, but it is critical to the job as most enterprise apps are data driven apps. And I think SQL is something that is very tough to master. – user23157 Apr 24 '11 at 9:03
up vote 0 down vote accepted

I highly recommend this book: SQL Cookbook I think it's what you're looking for, it describes common situations that come up (in question and answer form) and is really geared to programmers who have basic knowledge of T-sql but want to go further.

share|improve this answer

I would suggest an electronic book so you can have a copy at work for reference (search) and at home for study. Apress has a wide selection. Get an advanced book. Any concepts you don't understand can be found on the internet (Easier to search when you know what to look for.). not only has the QA of SO, but has articles and other how-tos specific to sql server.

share|improve this answer

I would like to recommend these 3 books authored by Itzik Ben-Gan:

  1. Microsoft® SQL Server® 2008 T-SQL Fundamentals (PRO-Developer)
  2. Inside Microsoft® SQL Server® 2008: T-SQL Querying
  3. Inside Microsoft® SQL Server® 2008: T-SQL Programming (Pro-Developer)

I would recommend to read the 1st book to obtain better overview of the various T-SQL syntax and their usages. Subsequently read the 2nd book to have a better understanding in how to use those T-SQL syntaxes.

The explanation is great, the examples are clear enough for us to follow. The 1st book offer many examples in how to use T-SQL combined with the practice examples.

share|improve this answer