November 7, 2013 at 7:13 pm
raulggonzalez (11/7/2013)
Thanks for the question!Considering that it states "choose 3 answers" and there was no name "JAMES", for me was pretty clear that the author assumed a case insensitive scenario.
+1 good question. thanks
Hope this helps...
Ford Fairlane
Rock and Roll Detective
November 9, 2013 at 4:15 am
I worked it out in my head, got it right, then ran the query on my system and got a different result: error in query. On my system NAME and Name are two different columns, because the server collation is case sensitive. But I am used to that - many QotD authors never test their questions on case sensitive servers. When making the necessary changes to make the code run, I noticed that two of the COALESCE functions use NULL instead of Name - a fact I had overlooked when working it out in my head (that luckily did not affect the result). Was this intentional??
The case insensitivity of the data was not an issue for me - the "select three" made it obvious that James = JAMES in this question.
November 9, 2013 at 6:29 am
raulggonzalez (11/7/2013)
Considering that it states "choose 3 answers" and there was no name "JAMES", for me was pretty clear that the author assumed a case insensitive scenario.
True; as the server default is CI.
Good question, thanks.
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
November 10, 2013 at 8:20 pm
Phew that took me about 10 minutes to do calculation on my mind.
Great question.
November 11, 2013 at 11:34 am
I like questions like this that make me think.
November 11, 2013 at 12:22 pm
Nice question, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
November 18, 2013 at 6:26 am
Hugo Kornelis (11/9/2013)
On my system NAME and Name are two different columns, because the server collation is case sensitive.
Really surprised nobody else has picked up on this, instead questioning the case sensitivity of the data. On my server (case sensitive collation), the correct answer was an error. But since we had to choose 3 answers, I made the correct assumption and got it right 🙂
November 19, 2013 at 4:20 am
murray-906152 (11/6/2013)
Steve,you state 'NOTE: You will notice that James was case insenstive (COLLATE SQL_Latin1_General_CP1_CI_AS )' in your answer but this is very much site specific.
(I answered on the basis that you were assuming a case insensitive environment.)
If the database one was playing in was defined with collation SQL_Latin1_General_CP1_CS_AS (for instance), as inherited from the model database on creation, then the results would be difference up front.
To avoid ambiguity, you could have forced the collation on table creation with:
CREATE TABLE TEST ( NAME VARCHAR(20) COLLATE SQL_Latin1_General_CP1_CI_AS);
Regards, Murray.
All our databases are defined as SQL_Latin1_General_CP1_CS_AS so I certainly wouldn't have got the 'correct' answer if I'd run the code.
November 19, 2013 at 4:22 am
Good Question ,,Thanks Steve
Pramod
SQL Server DBA | MCSE SQL Server 2012/2014
in.linkedin.com/in/pramodsingla/
http://pramodsingla.wordpress.com/
Viewing 9 posts - 16 through 23 (of 23 total)
You must be logged in to reply to this topic. Login to reply