Wednesday, November 01, 2006

Useless Query

I just ran across this in an SP and I thought I'd share it with you guys...

Select RegionName from Regions
where RegionName IN ('SC', 'MW', 'NE', 'NC', 'NW')


For some reason, I just love the uselessness of this whole thing.

2 comments:

Anonymous said...

There is a sense in that. Imagine the following table contents:

insert into Regions (RegionName)
select 'SC' union
select 'NW' union
select 'NA'

Now try your query. As you can see, output will be limited by both IN() list and table data. But yes, I doubt that authors of such crap ever think about this weird case... :)

Anonymous said...

Do I need to be American to understand the uselessness of this sp?

About Me

My Photo
Sean McCown
I am a Contributing Editor for InfoWorld Magazine, and a frequent contributor to SQLServerCentral.com as well as SSWUG.org. I live with my wife and 3 kids, and have practiced and taught Kenpo for 22yrs now.
View my complete profile

Labels

Blogumulus by Roy Tanck and Amanda Fazani

Page Views