Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Counting spaces Expand / Collapse
Author
Message
Posted Saturday, December 05, 2009 11:26 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing 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
Post #829429
Posted Sunday, December 06, 2009 4:10 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld 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.
Post #829572
Posted Sunday, December 06, 2009 7:58 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Sunday, May 19, 2013 8:08 PM
Points: 334, Visits: 389
yeah nice curve ball :)
Post #829598
Posted Sunday, December 06, 2009 11:16 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC 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....
Post #829656
Posted Monday, December 07, 2009 1:35 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC 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




Post #829693
Posted Monday, December 07, 2009 3:28 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

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"
Post #829717
Posted Monday, December 07, 2009 5:44 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing 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
Post #829769
Posted Monday, December 07, 2009 9:03 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 6:14 PM
Points: 31,421, Visits: 13,734
nice question, got me as well.

I'll correct the case sensitivity







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #829961
Posted Monday, December 07, 2009 9:11 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing 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
Post #829971
Posted Monday, December 07, 2009 11:24 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen 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.
Post #830110
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse