|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Yesterday @ 5:12 AM
Points: 649,
Visits: 686
|
|
Comments posted to this topic are about the item Counting spaces
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Sunday, May 12, 2013 11:47 PM
Points: 356,
Visits: 700
|
|
Excellent trick question. String comparison for both char & varchar ignores trailing spaces - even when ANSI_PADDING is ON.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Sunday, May 19, 2013 8:08 PM
Points: 334,
Visits: 389
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, January 10, 2011 2:10 AM
Points: 293,
Visits: 15
|
|
Yeah... That was a good one... made to think for a while....
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, April 01, 2013 11:51 PM
Points: 292,
Visits: 794
|
|
You need the option
Must declare the scalar variable "@Dec".
When running on a Case Sensitive collation. Once that select statement on line 2 is adjusted then it would work.
------ Robert
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 1:51 AM
Points: 1,971,
Visits: 1,821
|
|
rcavill (12/7/2009) You need the option
Must declare the scalar variable "@Dec".
When running on a Case Sensitive collation. Once that select statement on line 2 is adjusted then it would work.
------ Robert
Have good luck for "Case Sensitive collation"
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Yesterday @ 5:12 AM
Points: 649,
Visits: 686
|
|
rcavill (12/7/2009) You need the option
Must declare the scalar variable "@Dec".
When running on a Case Sensitive collation. Once that select statement on line 2 is adjusted then it would work.
------ Robert
I didn't even notice that capital "D"... I promise it wasn't meant to be any kind of case-sensitive trick question! Maybe a mod could fix that...
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Yesterday @ 6:14 PM
Points: 31,421,
Visits: 13,734
|
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Yesterday @ 5:12 AM
Points: 649,
Visits: 686
|
|
Steve Jones - Editor (12/7/2009) nice question, got me as well.
You just made my day, Mr. Jones.
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 9:31 AM
Points: 1,039,
Visits: 1,356
|
|
Technically speaking, the explanation for the answer is not correct. The explanation given is that SQL server ignores trailing spaces when comparing strings.
But in this example, SQL server isn't comparing strings at all. It's comparing integer values (the length of each string.)
The correct explanation is that SQL server ignores trailing spaces when calculating the length of a string.
|
|
|
|