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»»»

ALL Expand / Collapse
Author
Message
Posted Saturday, June 28, 2008 1:34 PM
SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, May 18, 2007 3:36 PM
Points: 10,039, Visits: 1
Comments posted to this topic are about the item ALL
Post #525535
Posted Saturday, June 28, 2008 7:14 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
Uh, steve, this "ALL" query is the same as the "ANY" query last week, but it now reports a different answer. NOTE that the word "ALL" does not appear anywhere in the question, a typo maybe?

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #525560
Posted Sunday, June 29, 2008 10:31 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 11:24 AM
Points: 33,088, Visits: 15,197
Thanks, must have cut and pasted the wrong query in there.

Corrected to be all.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #525629
Posted Sunday, June 29, 2008 10:50 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
Heh, don't suppose I'm getting my two points, eh?

Never mind, I'll take them from these replies. Besides, I wouldn't want any more "enlightened" posters accusing me of point-mongering.


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #525636
Posted Monday, June 30, 2008 1:41 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 3:22 PM
Points: 5,925, Visits: 8,174
Nice question, Steve.

Too bad you didn't use the same case in the query and the list of values, as this might (*) result in different answers being returned when tested in a database with case-sensitive or binary collation.

(*) "might", as I didn't bother to check if it reallly would. :)



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #525758
Posted Monday, June 30, 2008 2:59 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 31, 2008 2:42 AM
Points: 9, Visits: 24
Depends on whether the collation is case-sensitive or not. If it is the answer is 1...

--case sensitive
create table TimeGROUP(column1 varchar(255) COLLATE SQL_Latin1_General_Cp1_Cs_AS)

Insert into TimeGROUP (column1) values('value1')
Insert into TimeGROUP (column1) values('value2')
Insert into TimeGROUP (column1) values('value3')
Insert into TimeGROUP (column1) values('value4')


if 'Value1' < all ( select column1 from TimeGROUP ) select 1 else select 0

drop table TimeGROUP

--case insensitive
create table TimeGROUP(column1 varchar(255) COLLATE SQL_Latin1_General_Cp1_CI_AS)

Insert into TimeGROUP (column1) values('value1')
Insert into TimeGROUP (column1) values('value2')
Insert into TimeGROUP (column1) values('value3')
Insert into TimeGROUP (column1) values('value4')


if 'Value1' < all ( select column1 from TimeGROUP ) select 1 else select 0

drop table TimeGROUP
Post #525772
Posted Monday, June 30, 2008 4:21 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: Thursday, July 24, 2014 3:46 AM
Points: 692, Visits: 397
aggree with the collation thingie
also, the question mentions all lowercase strings while in the answer you mention VALUE1, which is all uppercase...
confusing, that's what I think...
Post #525787
Posted Monday, June 30, 2008 5:11 AM
SSC-Addicted

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

Group: General Forum Members
Last Login: Monday, June 16, 2014 4:03 AM
Points: 488, Visits: 403
pollockk (6/30/2008)
Depends on whether the collation is case-sensitive or not. If it is the answer is 1...

That's what I thought too, But the Q poser knew that, and knew that I knew that, and I knew that they knew that ... giving an answer alternating between 0 and 1 depending on when you stop.
*BUT*
The poser, by not giving an option of "it depends", or "Invalid object name 'TimeGROUP'" gives the game away .. because ..
** HERE BE SPOILERS **
The table is called 'TimeGroup' but the query is 'TimeGROUP'
If the DB was case-sensitive, then the query would NOT find the table, unless there was ANOTHER table TimeGROUP - and the result of the query was *indeterminate* - not an option - so ...
The DB must be Case-Insensitive !!
QED - kind of

Post #525803
Posted Monday, June 30, 2008 5:21 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 3:22 PM
Points: 5,925, Visits: 8,174
brewmanz (6/30/2008)
The table is called 'TimeGroup' but the query is 'TimeGROUP'
If the DB was case-sensitive, then the query would NOT find the table, unless there was ANOTHER table TimeGROUP - and the result of the query was *indeterminate* - not an option - so ...
The DB must be Case-Insensitive !!
QED - kind of


<nitpicking>
Except that it is perfectly possible to define a table with a case sensitive collation in a database with a case insensitive default collation...
</nitpicking>

However, I had no doubt whatsoever after reading the question that it was written without case sensitive collations in mind. The title of the question was "ALL", so it was clear that the author wanted to test understanding of this keyword, not ability to test some code by running it and then complaining if collations didn't match. I dare to state that anyone who really knows and understands the "ANY" keyword, should be able to answer this question correctly.

(Edit - fixed the fake HTML tags)



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #525807
Posted Monday, June 30, 2008 5:32 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 31, 2008 2:42 AM
Points: 9, Visits: 24
Of course these questions aren't about just running the SQL

The question's main intent is clear, it's a pretty simple question about ALL - and I am not at all trying to be nitpicky or garner extra points or anything - it was just that in trying to work it out *in my head *, I noticed the case, noticed that it could affect the comparison, noticed that there wasn't enough info to deduce the whether the comparison would be case-sensitive or not - and thought that that might be an interesting *addendum/comment* to the main point.

Maybe that's just because I have been caught by tables with case sensitive collations in real life.

Kirsty


EDIT: typo + reword for clarity of intent.
Post #525810
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse