I think I have a good grasp of SQL and the most features it has, but sometimes when I've done some more advanced Reporting Services a fellow developer has helped me with some stuff and when I open some existing procedures in T-SQL I understand that I have some learning to do. I think I have focused more in later years at application code (C# and javascript mostly) and somehow my SQL skills aren't there where It should be. Because at work the most stuff is very database centric with procedures, so I think I need to get better at SQL. But when I google around about features and look in books about SQL I know the most stuff, but somehow getting better at SQL ain't so easy any more. Does anybody have any advice how to become an advanced SQL programmer? What books to pick up? By the way I work exclusively with SQL Server.

I've done tons of basic procedures with inserts, updates, selects with joins and group by and so on. But doing bigger problems I've always done a more application-centric approach with arrays and collections, but sometimes (Reporting) there's no choice than do it in SQL and work with temporary tables and so on. I'm tempted to do cursors because then I can loop through everything but that kills database performance (how about looping through a half million rows with a cursor?).

| improve this question | | | | |
  • 3
    With the command explain ;) – deadalnix Oct 6 '11 at 17:46
  • 4
    The same way you get to Carnegie Hall: practice, practice, practice! – FrustratedWithFormsDesigner Oct 6 '11 at 17:54
  • With cursors specifically: if you find yourself using one, you are probably doing it the wrong way. :) – Joe Dec 15 '11 at 2:32

Generally, think sets.

  • Try to avoid OO and procedural code for a while. Forget about the next .net framework if you're serious. I left most non-SQL work behind years ago and never looked back.

  • Start following a more DB specific site actively like DBA.SE (which has development stuff too), even read the highest scoring answers to see coding techniques in action.

  • Pick up a book by Joe Celko or Bill Karwin for a theoretical view of sets and databases without overdoing it.

| improve this answer | | | | |
  • 2
    +0.5 for "think sets" and +0.5 for mentioning Joe Celko and Bill Karwin. – smwikipedia Apr 17 '14 at 7:40

The best bet is to fully grok a good database textbook from cover to cover. Then you apply all you know with sample DB projects.

Basically work really hard at it. Get good at remembering stuff too. Yeah it's all in the reference manuals, etc, but having it handy in your brain cache is super.

| improve this answer | | | | |

The temptation to do cursors is very common with procedural programmers. Focus on learning the set-based mindset behind great database programming, and you will become a superstar.

In addition to the Joe Celko and Bill Karwin books (recommendations enthusiastically seconded), the series of Microsoft Press books on SQL 2008 by Itzik Ben-Gan et al. are also top notch. They will whip you into shape and train you in the direction of sophisticated set-based problem solving.

After that, Kalen Delaney's book on SQL Server Internals (also from Microsoft Press) will explain the "why" behind a lot of things other books recommend and say "this performs better".

| improve this answer | | | | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.