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


Counting spaces


Counting spaces

Author
Message
ronmoses
ronmoses
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1251 Visits: 996
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
Mr or Mrs. 500
Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)

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

Group: General Forum Members
Points: 435 Visits: 504
yeah nice curve ball Smile
rajaneeshk
rajaneeshk
SSC Veteran
SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)

Group: General Forum Members
Points: 293 Visits: 15
Yeah... That was a good one... made to think for a while....:-)
rcavill
rcavill
Old Hand
Old Hand (330 reputation)Old Hand (330 reputation)Old Hand (330 reputation)Old Hand (330 reputation)Old Hand (330 reputation)Old Hand (330 reputation)Old Hand (330 reputation)Old Hand (330 reputation)

Group: General Forum Members
Points: 330 Visits: 850
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
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5067 Visits: 3327
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"

I run on tuttopodismo
ronmoses
ronmoses
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1251 Visits: 996
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 (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: Administrators
Points: 64749 Visits: 19118
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
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1251 Visits: 996
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
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2651 Visits: 2833
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