Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

How do you solve T-SQL problems? Expand / Collapse
Posted Monday, May 20, 2013 10:55 PM



Group: Administrators
Last Login: Today @ 1:59 PM
Points: 34,363, Visits: 18,582
Comments posted to this topic are about the item How do you solve T-SQL problems?

Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1454812
Posted Tuesday, May 21, 2013 6:25 AM


Group: General Forum Members
Last Login: Friday, December 2, 2016 6:09 AM
Points: 485, Visits: 1,130
"Moving forward she asked for help, which is perfectly acceptable way of working in your career. Try to solve it yourself, get a solution working, and then ask if it can be improved. Not only did she end up with a better performing solution, but she learned a bit more along the way. Something we all can do."

The above extract (with the emphasis added by me) is, to me, the most important part of Steve's editorial. While I believe most who participate on this site do ask for help, it often amazes me how many never do, and then wonder why others feel they write and get away with such sucky code.

I always tell people that the only stupid question is the one you don't ask. I try to work that both ways; I try not to be afraid to ask for help and I tell myself when I get what I think is a trivial question that once I didn't know that answer, either.
Post #1454964
Posted Tuesday, May 21, 2013 4:41 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, November 30, 2016 3:58 PM
Points: 368, Visits: 1,973
To me this is an very interesting editorial and I'm a bit shocked that there aren't about five pages of comments by now instead of a single (and thoughtful) post.

Maybe Americans are getting started on Memorial Day already but that isn't any excuse for the rest of the world. I'd love to hear what you have to say on the subject (and don't we all love to talk about what we think we're good at?).

My two bits:
It begins with problem definition. Johnism: "Undefined problems are unresolved problems". If you can't articulate the issue you are not going to resolve it.

Having a handle on the problem, my next move is to delineate the steps between where I am and where I need to be (the "strategic gap"). Sometimes I do this mentally and sometimes I write them down. Also, I will usually have a good idea at this point if I am going to need help or not.

One very simple thing I usually do before writing a single query is to write a single comment describing what I want that particular query to accomplish. It provides focus for me and a pointer for someone who might follow me someday.

Lastly, I look for opportunities to utilize the techniques you wonderful folks share with the rest of us on a daily basis. I still can't stand in the same room as the very best of you but because of you, I am twice the programmer I was before I started frequenting SSC.
Post #1455255
Posted Wednesday, May 22, 2013 6:03 AM



Group: General Forum Members
Last Login: Today @ 12:18 PM
Points: 7,905, Visits: 5,949
I think that the first version should be a simple (as per Einstein's definition) set based query that resolves the business question. Of course, this assumes that it is a suitable piece of functionality for this approach. After that you have the basis to perform optimisations as appropriate. It is then worth commenting why optimisations were applied as the optimisations for one SQL Server release may not apply to another etc.


-- Stop your grinnin' and drop your linen...they're everywhere!!!
Post #1455443
Posted Wednesday, May 22, 2013 6:33 AM


Group: General Forum Members
Last Login: Thursday, May 5, 2016 3:59 PM
Points: 126, Visits: 615
declare @i int,@done bit
select @i = 0, @done = false
while i<10
try something
observe effects
modify approach
if works then
set @done = 1
if not @done
seek help

Post #1455452
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse