|
If I am working with the technology that is using different approach than sql. How to modify my mind to think in that direction? For example, if i am working with java. I am thinking about object. And if I am working with sql i have to think about set. But how?
(comments are locked)
|
|
One word - Practice. Practice and Testing. Practice using TSQL in a set based way, Any search for "Tally Table" or "Numbers Table" or "Jeff Moden" will be a great place to start. He has some great articles on www.SQLServerCentral.com. +1 for the Spanish Inquisition.
May 12 '10 at 09:17 AM
Grant Fritchey ♦♦
practice is more important thing, i think i will learn as i am wirking with sql.
May 12 '10 at 09:42 AM
Dharmendra
I second the recommendation for Jeff Moden's articles, and add Joe Celko's (see simple-talk.com amoungst other places for some). Those two authors do perhaps the best job of helping people learn to switch to set based thinking.
May 12 '10 at 11:08 AM
TimothyAWiseman
Oh my... you good folks certainly have me blushing. Thank you for your good thoughts... I'm truly humbled.
May 14 '10 at 07:53 PM
Jeff Moden
(comments are locked)
|
|
I agree with the above, but here is something that might help you think about it. Java is a 3GL (Third generation language), same as C#, VB.NET etc. In a 3GL you tell the computer how to do what it is you're asking it to do. SQL is a 4GL (Fourth generation language), and the idea with a 4GL is that you tell the computer what it is that you want. Putting that in a more human scenario - Imagine you have a factory which makes widgets. You have workers in that factory that follow a set of instructions on how to make a widget. These instructions were created by somebody who looked at the specification of what a widget was, and decided how to make it. The instructions are the 3GL, the specification is the 4GL. Try to think about what it is you're trying to achieve, rather than how to achieve it. That having been said, you will learn, over time, that you need to help SQL along it's way, and give it some hints as to how. You can read some more about it here...
(comments are locked)
|
|
As hard as it is, don't think about how to get what you want, think about what you want. Think about the columns that you want to retrieve, not the rows. Every time you find yourself starting to write a cursor, stop. Then try to wrap your head around how you could do the same thing with a set operation. That's about the best advice I can offer. Other than that, I'd suggest reading Itzik Ben Gan's books on TSQL. There just isn't a better place to get started on the understanding of what's happening when you write a query. +1 - great reading source and sound advice to avoid using the C word.
May 12 '10 at 09:32 AM
Fatherjack ♦♦
+1 for how to think. I even have it in my signature line on SQLServerCentral... First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
May 14 '10 at 07:50 PM
Jeff Moden
Heck Jeff, that's probably where I got it originally.
May 17 '10 at 10:47 AM
Grant Fritchey ♦♦
(comments are locked)
|
|
Read the best practices and stick to it for some time and you will get a hang of it slowly.
(comments are locked)
|

