|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 1:49 AM
Points: 1,182,
Visits: 745
|
|
Richard Warr (11/16/2010) I thought it was an interesting question as well - currently more people have it wrong than right which shows that we can still be surprised at the "behind the scenes" antics of SQL Server.
More people may have it wrong than right but its got less to do with the "behind the scenes" antics of SQL Server and more to do with the traps deliberately put into the question.
I've seen this problem before, and resolved it by seperating the CASE statement as suggested previously... however the traps set in the question tripped me up in this case.
_____________________________________________________________________ "The difficult tasks we do immediately, the impossible takes a little longer"
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 4:16 AM
Points: 1,635,
Visits: 1,155
|
|
tommyh (11/16/2010)
[quote] Richard Warr (11/16/2010)
You shouldnt complain about spelling. This is an international site and as long as you can understand what someone else writes... its okay. Perfect spelling/grammar is rare. Also considering your own "taime" spelling... well... mistakes happen  /T (non native english speaker)
Fair point - nobody's perfect!
Perhaps that distracted from what I was saying about having respect for all users and contributors though. And ever since Microsoft designated "British English" a foreign language we're in the same boat!
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Today @ 11:49 AM
Points: 662,
Visits: 699
|
|
tommyh (11/16/2010)
Richard Warr (11/16/2010) Please don't describe questions as "nonsense", people take taime to set them and always have good intentions when they do so. It doesn't help your case if you can't spell "nonsense" either.You shouldnt complain about spelling. This is an international site and as long as you can understand what someone else writes... its okay. Perfect spelling/grammar is rare. Also considering your own "taime" spelling... well... mistakes happen  You shouldn't complain about people who complain about spelling on the part of people who complain about describing questions as "nonsense." Too many nested complaints will make your thread difficult to read and maintain. Instead, those complaints should be broken out into their own threads and called from the main thread.
 ron
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Yesterday @ 1:46 PM
Points: 581,
Visits: 700
|
|
| I got tripped up by the implicit conversion. That should teach me to answer these questions before properly caffeinated. Thanks for the question!
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Yesterday @ 6:30 AM
Points: 9,410,
Visits: 6,495
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 7:16 AM
Points: 2,030,
Visits: 2,869
|
|
I got the question correct but not because I knew what I was doing. I haven't written T-SQL for very long and don't write complex code. I looked at the CASE statements in the ORDER BY and didn't know you could do that. It looked funny, so, I picked none of the above. 
Tha could come in handy some day. Thanks.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 8:36 AM
Points: 2,681,
Visits: 2,423
|
|
| I don't understand the implicit conversion. Why is it happening?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 3:54 PM
Points: 1,334,
Visits: 4,021
|
|
Daniel Bowlin (11/16/2010) I don't understand the implicit conversion. Why is it happening?
Hi Daniel, good question!
Microsoft http://msdn.microsoft.com/en-us/library/ms190309.aspxWhen an operator combines two expressions of different data types, the rules for data type precedence specify that the data type with the lower precedence is converted to the data type with the higher precedence. If the conversion is not a supported implicit conversion, an error is returned. When both operand expressions have the same data type, the result of the operation has that data type. SQL Server uses the following precedence order for data types: user-defined data types (highest) sql_variant xml datetimeoffset datetime2 datetime smalldatetime date time float real decimal money smallmoney bigint int smallint tinyint bit ntext text image timestamp uniqueidentifier nvarchar (including nvarchar(max) ) nchar varchar (including varchar(max) ) char varbinary (including varbinary(max) ) binary (lowest)
MM
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 3:54 PM
Points: 1,334,
Visits: 4,021
|
|
Thanks to those of you who appreciate this question.
To those who think it had unnecessary "tricks" in it, I did try several variants of this question and they all ended up being too easy.
The "tricks" were deliberate and designed to check whether you would notice the implicit conversion and whether you even knew it would happen.
If you don't like the question, I am sorry - for those that like to be challenged to check every small detail I think it provides a sufficient level of complexity to give you a good challenge!
Have a nice day!
MM
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 7:18 AM
Points: 1,996,
Visits: 1,864
|
|
mister.magoo (11/16/2010) Thanks to those of you who appreciate this question.
To those who think it had unnecessary "tricks" in it, I did try several variants of this question and they all ended up being too easy.
The "tricks" were deliberate and designed to check whether you would notice the implicit conversion and whether you even knew it would happen.
If you don't like the question, I am sorry - for those that like to be challenged to check every small detail I think it provides a sufficient level of complexity to give you a good challenge!
Have a nice day!
I agree! Tricks train the eyes to see bugs quickly!
|
|
|
|