SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Counting spaces


Counting spaces

Author
Message
ronmoses
ronmoses
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1852 Visits: 1013
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

Ol'SureHand
Ol'SureHand
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1009 Visits: 720
Excellent trick question.
String comparison for both char & varchar ignores trailing spaces - even when ANSI_PADDING is ON.
TroyG
TroyG
SSC Eights!
SSC Eights! (899 reputation)SSC Eights! (899 reputation)SSC Eights! (899 reputation)SSC Eights! (899 reputation)SSC Eights! (899 reputation)SSC Eights! (899 reputation)SSC Eights! (899 reputation)SSC Eights! (899 reputation)

Group: General Forum Members
Points: 899 Visits: 504
yeah nice curve ball Smile
rajaneeshk
rajaneeshk
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 15
Yeah... That was a good one... made to think for a while....:-)
rcavill
rcavill
SSC-Addicted
SSC-Addicted (492 reputation)SSC-Addicted (492 reputation)SSC-Addicted (492 reputation)SSC-Addicted (492 reputation)SSC-Addicted (492 reputation)SSC-Addicted (492 reputation)SSC-Addicted (492 reputation)SSC-Addicted (492 reputation)

Group: General Forum Members
Points: 492 Visits: 854
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



Carlo Romagnano
Carlo Romagnano
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8270 Visits: 3410
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"
ronmoses
ronmoses
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1852 Visits: 1013
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! :-D Maybe a mod could fix that...

-----
a haiku...

NULL is not zero
NULL is not an empty string
NULL is the unknown

Steve Jones
Steve Jones
SSC Guru
SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)SSC Guru (180K reputation)

Group: Administrators
Points: 180324 Visits: 19497
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
My Blog: www.voiceofthedba.com
ronmoses
ronmoses
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1852 Visits: 1013
Steve Jones - Editor (12/7/2009)
nice question, got me as well.


You just made my day, Mr. Jones. :-D

-----
a haiku...

NULL is not zero
NULL is not an empty string
NULL is the unknown

sknox
sknox
SSCarpal Tunnel
SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)

Group: General Forum Members
Points: 4589 Visits: 2967
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search