Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Teaser: uniqueidentifier

Status
Not open for further replies.

SQLDenis

Programmer
Oct 1, 2005
5,575
US
Code:
create table #Foobahar (id int,Col uniqueidentifier)
insert #Foobahar values(1,'FD788D60-E5F8-4969-9733-F88186B7EE63')
insert #Foobahar values(2,'78E89339-F5A0-46B9-961E-AC4681B63075')
insert #Foobahar values(3,'BE9E0439-5626-42B5-955B-1FD831BF7CAF')


without running this, which GUID do you think will be returned
Code:
select min(Col) from #Foobahar

Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
SQLBlog.com, Google Interview Questions
 
Either

FD788D60-E5F8-4969-9733-F88186B7EE63

Or

78E89339-F5A0-46B9-961E-AC4681B63075

Or

BE9E0439-5626-42B5-955B-1FD831BF7CAF


Christiaan Baes
Belgium

"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
Chrissie,

Would you be surprised to know that all of your choices are wrong?

-George

"the screen with the little boxes in the window." - Moron
 
No

Christiaan Baes
Belgium

"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
I'd guess that you get some red text in the messages tab...

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
None. You cannot use an aggregate function on a uniqueidentifier. Nor can you use one on bit fields. And probably some other types I cannot think of right now.
 
And these...

Code:
SELECT Convert(uniqueidentifier, Min(Convert(binary(16), Col))) from #Foobahar

SELECT Convert(binary(16), col) from #Foobahar

[COLOR=black #d0d0d0]My alarm clock causes time travel. When I hit snooze, no apparent time passes before the alarm sounds again, but the universe has in fact moved forward through time by ten minutes![/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top