SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


ALL


Author
Message
Site Owners
Site Owners
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: Administrators
Points: 14907 Visits: 114
Comments posted to this topic are about the item ALL
RBarryYoung
RBarryYoung
SSC Guru
SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)

Group: General Forum Members
Points: 55164 Visits: 9518
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."
Steve Jones
Steve Jones
SSC Guru
SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)

Group: Administrators
Points: 223868 Visits: 19631
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
My Blog: www.voiceofthedba.com
RBarryYoung
RBarryYoung
SSC Guru
SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)SSC Guru (55K reputation)

Group: General Forum Members
Points: 55164 Visits: 9518
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."
Hugo Kornelis
Hugo Kornelis
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25037 Visits: 12583
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. Smile


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
pollockk
pollockk
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 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
thierry.vandurme
thierry.vandurme
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1666 Visits: 566
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...
brewmanz
brewmanz
SSC Eights!
SSC Eights! (903 reputation)SSC Eights! (903 reputation)SSC Eights! (903 reputation)SSC Eights! (903 reputation)SSC Eights! (903 reputation)SSC Eights! (903 reputation)SSC Eights! (903 reputation)SSC Eights! (903 reputation)

Group: General Forum Members
Points: 903 Visits: 406
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
Hugo Kornelis
Hugo Kornelis
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25037 Visits: 12583
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
pollockk
pollockk
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search