Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?).

share|improve this question

closed as off-topic by gnat, GlenH7, MichaelT, Thomas Owens Mar 22 at 10:55

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

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, GlenH7, MichaelT, Thomas Owens
If this question can be reworded to fit the rules in the help center, please edit the 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
    
Type this code: AdvLevel –  Job Dec 15 '11 at 2:19
    
With cursors specifically: if you find yourself using one, you are probably doing it the wrong way. :) –  Joe Dec 15 '11 at 2:32
add comment

3 Answers

up vote 9 down vote accepted

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.

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

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.

share|improve this answer
add comment

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".

share|improve this answer
add comment

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