Jeff's SQL Server Blog

Random Thoughts & Cartesian Products with Microsoft SQL Server
posts - 157, comments - 2686, trackbacks - 64

My Links

Advertisement

News

Welcome to my weblog. My name is Jeff Smith, I am software developer in Boston, MA and I was recently named a 2009 SQL Server MVP. Check in frequently for tips, tricks, commentary and ideas on SQL Server and .NET programming.


Subscribe





Archives

Post Categories

Programming

Sports

SQL

The Joy of Blog Feedback

Introduction

I have been writing my little blog here for some time now, and my favorite part of doing this is of course the feedback.  It's always great to hear from the readers, to have mistakes corrected, to debate various topics and techniques, and to learn a lot about SQL and the various topics I discuss here. 

At this point, I have received over 1,700 comments over the years, and while all of them are truly appreciated, I have noticed that unfortunately many of the, uh, less helpful comments do seem to consistently fall neatly into various categories. 

Let's take a look at an example of a simple, typical blog post and some of the responses that often come back.  If you write a blog of your own, or often read the feedback from other blogs, many of these may seem familiar to you. 

A Typical Blog Post


Today, I have a simple tip for beginner SQL programmers.  When writing a SELECT, you can add a WHERE clause to filter the results that are returned.

For example, to only return rows for CustomerID 345, you can write:

SELECT ...
FROM YourTable
WHERE CustomerID = 345

As you can see, it is very simple. You can use any boolean expression to filter the results as needed. Try it out!  If you have any questions, let me know.

Some Typical Responses

The subtle blog spammer (that you initially mistake for a nice complement):

Very helpful site! Good advice!  From Joe at www.some-random-site-that-has-nothing-to-do-with-sql.com

The person who doesn't seem to get it:

Ummm ... what good does this do when I want to sort? You should fix the code.

The person that really doesn't get it:

The problem with that is it will only return results for one customer.

The person that somehow takes away the exact opposite of what you wrote:

I disagree, this will not return all customers other than 345 and this is definitely not something for advanced SQL Programmers, it's probably better for beginners.

The script kiddie (who just wants to cut and paste your code, not read or learn anything):

LOL, that doesnt even run 4 me!  I get errorz that sez "YourTable" does not exist!  Plz help!!  thnx!

The very clichéd, mindless "anti-Microsoft ranter":

You only have to use WHERE clauses because Bill Gates wants more $$, you are a shill!! Micro$oft sucks, you should use an iPhone for this!  MySQL automagically filters results for you!

The "skimmer" (who just skims the post missing most of it):

Nice, but is there any way to filter for just one customer?

The "repeater" (who just repeats what you've already written):

A better solution is to write WHERE CustomerID = 345, it works better.  It is also fast because less rows are returned.  Using WHERE is a good way to filter a SELECT.

The "know-it-all complainer":

That is the stupidest advice I ever read, why would you want to ever do this? Just use a parameter, or an ORM tool-- this will not scale!  I sure hope CustomerID isn't a VARCHAR -- then you have an implicit conversion happening, your indexes are shot, your server will overheat, and your wife will leave you for your mechanic.  Also, 345 is too large if CustomerID is a tinyint.

The random, unrelated question asker:

Good advice. Thnx.  How to insert into the table?

The "misunderstander":

If I add this to all of my scripts, only data for one customer will ever be returned.  I am not sure this is a good idea. Also, this code will not work in Java and doesn't follow the HTML 4.0 specification. 

The very rare polite and helpful typo alerter:

Hey there, you have a typo in the first sentence -- should be "filter", not "fitler"! Just letting you know, thanks for a great post!

The much more common typo alerter:

You wrote FITLER not FILTER, your an idiot!! if you cannot write English how can you write SQL ???   Learn to spell!

Summary

Please, don't misunderstand, I mean this all in good fun.  I love feedback, and please, keep it coming.  It's what makes this and every other blog a fun place to visit.

In fact, I realize that I left out the most annoying feedback of all!  That's right, the Thin-Skinned, Overly-Defensive Blog Author Who Feels the Need to Respond to Everything:

Did you even read what I wrote? I did not say that.  And, yes, I did spell "monkey" wrong, so sue me!  Remind me to fire my editor.... or maybe I should refund your subscription fee?  Oh, wait, this blog is free!  So what the heck are you complaining about?  Why don't you go bother some MySQL blogger?  I hear they usually write at a 5th grade level which is probably more appropriate for your intellect. Jerk!

Yeah, comments like those are definitely the worst of all!  Thank you for putting up with my feedback, now that I think of it!

Print | posted on Friday, June 06, 2008 3:43 PM | Filed Under [ Miscellaneous Humor ]

Feedback

Gravatar

# re: The Joy of Blog Feedback

My sentiments exactly!
6/6/2008 4:59 PM | Tara
Gravatar

# re: The Joy of Blog Feedback

What an idiot! You're a loser Jeff. You totally missed the reformatter!

Everyone knows that you're supposed to do it this way:

SELECT
.
,.
,.
FROM YourTable
WHERE CustomerID = 345;
6/6/2008 8:43 PM | Don R. Watters
Gravatar

# re: The Joy of Blog Feedback

Nice post. It is nice to know that you read the comments. I notice that you have a link to the Red Sox Foundation nicely placed where commenters can see it. I'll have to assume you are a fellow Red Sox fan. That makes me more likely to continue to read your blog.

BTW - I figure anyone who is willing to take the time to try to contribute to the community for nothing should be commended, regardless of the quality of the content. It takes some courage to put your opinions and knowledge out there when there are so many critics.
6/6/2008 10:50 PM | Jack D Corbett
Gravatar

# re: The Joy of Blog Feedback

I hope this will fall into a new category that makes you continue to love comments.

I have learned a tremendous amount from reading your blog over the past several months. In fact, I am back today to completely absorb a post that answers something I have wondered how to do for a long time.

I really appreciate your dedication.
6/9/2008 10:50 AM | Bob Hopkins
Gravatar

# re: The Joy of Blog Feedback

Thanks for the chuckle!
6/10/2008 5:26 PM | Mary
Gravatar

# re: The Joy of Blog Feedback

One more (serious) comment about your first response type.

Are you so sure it's spam? I'm a software developer but I'm also into eating right. I blog about how I feed my family healthy food on a budget. I read your blog regularly and usually leave my URL when posting a comment (I'm ashamed to right now because I haven't updated my blog in two weeks.)

Personally I like to click on people's URL's when perusing the comments. Sometimes someone posts something insightful or funny and I wind up sidetracked yet totally delighted with a new find on the web.

Agreed that it's annoying to click on said URL and wind up with a screaming headline promising megabucks working one hour from home ...
6/10/2008 5:33 PM | Mary
Gravatar

# re: The Joy of Blog Feedback

LOL funny man ..this is my first time visiting ur blog.. but im pretty sure that i will be visiting here so soon
6/11/2008 10:18 AM | Paing
Gravatar

# re: The Joy of Blog Feedback

Hi Mary--

That's the problem -- you never know for sure! Sometimes it is tricky to figure out.
6/11/2008 2:27 PM | Jeff
Gravatar

# re: The Joy of Blog Feedback

I tried to run your query in my table but I don't have a column called ... You need to debug your code before posting it for the world to see! :) :) :)
6/13/2008 9:56 AM | Zack Jones
Gravatar

# re: The Joy of Blog Feedback

Thanks for the good advice, Jeff, but consider the following:

CREATE VIEW Customer345 AS
SELECT *
FROM Customer
WHERE CustomerID = 345

Your original, complex query now simplifies to

SELECT *
FROM Customer345

which is more readable and easier to maintain. If you happen to have more than one customer in your table (which is rarely the case), I can show you some really cool dynamic sql to create the according views.

Also note that you now have encapsulation and hide implementation details from other users who may want to use your query.

Only thing we have to worry about: what happens if new customers enter the table? Well that's what triggers are for, aren't they? Luckily we only need an INSERT trigger, no need to mess around with UPDATE and DELETE triggers!

Finally, due to our gain in simplicity we don't have to handle confusing stuff like GROUP BY and ORDER BY, since we ensured that our views never contain more than one row!

Hope that helps,
Bjoern
7/9/2008 8:24 AM | BjoernS
Gravatar

# re: The Joy of Blog Feedback

i'm surprised i have not seen your blog sooner via google, other links etc. you have really good stuff! (well not this particular article lol).
7/13/2008 11:07 PM | mario
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET