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


ALL


Author
Message
RBarryYoung
RBarryYoung
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19072 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 (81K reputation)SSC Guru (81K reputation)SSC Guru (81K reputation)SSC Guru (81K reputation)SSC Guru (81K reputation)SSC Guru (81K reputation)SSC Guru (81K reputation)SSC Guru (81K reputation)

Group: Administrators
Points: 81782 Visits: 19212
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
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19072 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
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13125 Visits: 12165
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
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
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
thierry.vandurme
thierry.vandurme
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1111 Visits: 545
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
SSChasing Mays
SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)SSChasing Mays (641 reputation)

Group: General Forum Members
Points: 641 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
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13125 Visits: 12165
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
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
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.
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13125 Visits: 12165
pollockk (6/30/2008)
Maybe that's just because I have been caught by tables with case sensitive collations in real life.


Thanks for the clarification, Kirsty Smile

I'm glad you took the question as I think the author intended it, and that you're not one of the whiney "I want my point back" types that this site unfortunately appears to have too many of (I am in fact surprised that as of yet, there still aren't two to three pages of such replies w00t ).

And I know all about being caught by this - most of my databases use a binary collation (for that tiny bit of extra speed Smile), so I often have to correct lots of upper-/lowercase problems when copying sample code from any online resource... Sad


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
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