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 5, 2009 11:26 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 9:36 AM
Points: 862, Visits: 863
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 6, 2009 4:10 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Saturday, June 21, 2014 6:12 AM
Points: 370, Visits: 715
Excellent trick question.
String comparison for both char & varchar ignores trailing spaces - even when ANSI_PADDING is ON.
Post #829572
Posted Sunday, December 6, 2009 7:58 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 9, 2014 9:36 PM
Points: 343, Visits: 417
yeah nice curve ball :)
Post #829598
Posted Sunday, December 6, 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 7, 2009 1:35 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, May 1, 2014 12:48 AM
Points: 292, Visits: 810
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 7, 2009 3:28 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 1:23 AM
Points: 2,509, Visits: 2,386
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 7, 2009 5:44 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 9:36 AM
Points: 862, Visits: 863
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 7, 2009 9:03 AM


SSC-Dedicated

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

Group: Administrators
Last Login: Today @ 12:57 PM
Points: 33,206, Visits: 15,361
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 7, 2009 9:11 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 9:36 AM
Points: 862, Visits: 863
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 7, 2009 11:24 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 5:11 AM
Points: 1,316, Visits: 1,687
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