Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

T-SQL Logic Expand / Collapse
Author
Message
Posted Tuesday, June 22, 2010 8:10 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, September 14, 2010 8:24 AM
Points: 69, Visits: 33
there are no negative database ids :)

and there is no 0

thus 1 is the answer to the most obfuscated question ever!
Post #941070
Posted Tuesday, June 22, 2010 8:34 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, May 15, 2014 8:31 AM
Points: 419, Visits: 725
Yeah, the question is overly complicated, and the answer is overly simple. The POWER() function is totally unneccessary, its fairly obvious from the WHERE clause that there's only going to be one row result. Not to mention the WHERE clause is redundant, as both branches will select the master database and only that database.

Really, I don't think it's a good question. It's complicated apparently just for the sake of being complicated. Save for learning that the database_id of the master database is always 1, no one will really actually bring anything away from this question.

--J
Post #941097
Posted Tuesday, June 22, 2010 8:37 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 8:40 AM
Points: 1,715, Visits: 6,265
I think it's a good question - designed to make you think a bit and work out that you don't actually need to know anything about database ids in order to get it right.
Post #941101
Posted Tuesday, June 22, 2010 8:47 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, September 19, 2012 8:39 AM
Points: 595, Visits: 1,226
Nice question. Thanks.

Converting oxygen into carbon dioxide, since 1955.

Post #941107
Posted Tuesday, June 22, 2010 8:55 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 7:45 AM
Points: 3,879, Visits: 3,622
ziangij (6/22/2010)
and database_id < 2

this was enough to answer the question...


Yes, if 10 would have been a possible answer it would have forced me to at least look at the rest of the Query.
Post #941113
Posted Tuesday, June 22, 2010 9:31 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, July 11, 2014 12:42 PM
Points: 1,380, Visits: 2,682
Thanks for the question. At first glance it looked like it was going to be really difficult/complicated but ended up being simple and fun.

---------------------------------------------------------------------
Use Full Links:
KB Article from Microsoft on how to ask a question on a Forum
Post #941145
Posted Tuesday, June 22, 2010 10:07 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Sunday, April 27, 2014 6:26 AM
Points: 1,521, Visits: 3,036
OCTom (6/22/2010)
And the point is?... lost on me... again.

Yes, it was relatively simple to analyze, but some of the QOD's should be at an elementary level. Not all members of this community are seasoned DBAs or developers.

As a note, I often try, as I did this time, to predict an answer from the copy of the question in the email newsletter, before seeing the multiple choices. That approach does crank up a few extra brain cells.

Henrico, thanks for submitting this one. I'm taking a reminder here that sometimes it's best to break down a problem first and see if a simple component (ID < 2) will give the answer without having to delve into the complicated other parts. It's like those math riddles which have all sorts of strange stuff and end up with the anwer being zero: ((ln 23 / (19^16))*((2^3)-(64^0.5))
Post #941180
Posted Tuesday, June 22, 2010 10:42 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Friday, June 27, 2014 1:42 PM
Points: 711, Visits: 677
I chose option 4 because I didn't know that there were no negative DB ID's. It would not be unlike MS to use negative ID's for system objects.

Now I know.
Post #941213
Posted Tuesday, June 22, 2010 10:50 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, June 16, 2014 9:38 AM
Points: 2,163, Visits: 2,189
Interesting question, but I don't know that I would expect everyone to have the system DB IDs memorized. (Or even to know that DBs have IDs.) But given some basic understanding of the ID information the answer was very easy to pick out.
Post #941221
Posted Tuesday, June 22, 2010 4:54 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 6:45 PM
Points: 21,351, Visits: 15,030
Thanks for the Question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #941416
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse