SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Archives: May 2011

SQL Query Run Time Estimation

A followup to a post about subqueries with an estimation for how long it would take for the query to run.

In a recent post about subqueries, I compared 4 queries and how they handled 4 million rows of data. The queries involved:

1) Joins with AND conditions.
2)… Read more

0 comments, 2,341 reads

Posted in Help With SQL on 30 May 2011

Using Views for Faster SQL Query Development

A discussion of how views give a more denormalized means for querying against normalized tables.

Ad-hoc reports are frequently requested at the Boston Public Schools. Generally each request is different but similar to ones previously made. To the degree that such requests are unique, there’ll always be work involved in… Read more

1 comments, 760 reads

Posted in Help With SQL on 28 May 2011

Random Ordering of Results using NEWID

A discussion of how NEWID can be used to help randomize the results returned from a SQL query.

A scenario I hadn’t encountered until recently is as follows: How does one get a certain number of randomly selected records from a table? Nope, I didn’t need to do this for… Read more

0 comments, 1,053 reads

Posted in Help With SQL on 26 May 2011

Efficiency of Subqueries and OR conditions in SQL

A discussion of how joins significantly outperform subqueries and how this is more evident when OR conditions are involved.

SQL queries can be written in a number of ways and be functionally equivalent but significantly different speed-wise. A great example of this is the use of cross joins instead of… Read more

0 comments, 859 reads

Posted in Help With SQL on 25 May 2011

Double digits in posts!

Thank you to everyone reading this site - Please enjoy your stay!

HelpWithSQL has hit double digits in posts! I hope everyone visiting the site finds the content and examples useful and interesting. The site has quickly evolved over the last couple weeks and it will continue to do so.… Read more

0 comments, 567 reads

Posted in Help With SQL on 24 May 2011

SQL Joins and Subqueries

A discussion about SQL joins and subqueries with information about how to format join statements properly.

In any non-trivial task, developers need to join tables together. Joins are important when we want to:

    1) Display/get data from more than 1 table in a result set.
    2) Filter out records based…

Read more

1 comments, 1,009 reads

Posted in Help With SQL on 22 May 2011

Forum Fun: Running Calculation SQL

A discussion about a forum post for handling a running subtraction in a SQL query.

For my first forum fun post, I’m going to discuss a running calculation SQL question posted by a user, asyssolvers, on the SQLTeam website here. Here’s the question [slightly shortened]:

I need to get…

Read more

0 comments, 624 reads

Posted in Help With SQL on 21 May 2011

Answering SQL Questions and Forum Fun Overview

Why SQL questions are interesting and how I'm using forums to challenge myself and help others.

I like a good SQL challenge. If I see a problem and it looks complex but do-able, I jump at it. Similar to how some people work through a crossword puzzle or a Sudoku… Read more

0 comments, 608 reads

Posted in Help With SQL on 19 May 2011

Where to put the logic? SQL? Code?

A discussion of where logic should go and why SQL might be the best place.

SQL is a powerful language and is very good at what it was made for – querying sets of data. C#, Java, and other languages are also powerful – more powerful than SQL in many… Read more

0 comments, 786 reads

Posted in Help With SQL on 18 May 2011