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»»

LEN() Expand / Collapse
Author
Message
Posted Monday, June 14, 2010 8:43 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, May 30, 2014 3:50 AM
Points: 99, Visits: 176
Comments posted to this topic are about the item LEN()
Post #937222
Posted Monday, June 14, 2010 8:44 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, June 16, 2014 9:38 AM
Points: 2,163, Visits: 2,189
Good question, thanks!

Though I probably would have had the second option be 5, 2, 3...
Post #937223
Posted Monday, June 14, 2010 11:38 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 15, 2013 11:19 PM
Points: 9, Visits: 64
what's new in this question ?????
Post #937248
Posted Tuesday, June 15, 2010 1:20 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:46 AM
Points: 13,622, Visits: 10,513
One easy point for me!



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #937281
Posted Tuesday, June 15, 2010 2:15 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354, Visits: 1,299
This one got me. I selected 5,5,5 because I'm used to having padding spaces with the CHAR datatype. That's why I use Varchar instead when the contents of the column doesn't contain a consistent number of characters.

if you were to select them without the LEN function, you would get
abcde ab... ab...

(the period was used to make spaces visible).

Post #937305
Posted Tuesday, June 15, 2010 2:37 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 10:21 AM
Points: 1,219, Visits: 2,210
It's probably also worth pointing out that if you actually did want the physical length of the variables, you would use DATALENGTH() instead of LEN().
Post #937314
Posted Tuesday, June 15, 2010 3:03 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, August 27, 2013 4:28 AM
Points: 1,248, Visits: 779
Aargh!! Again my initial reaction was "that's easy it's 5,2,2 as LEN ignores spaces"... and then "hmmm, but that's too easy, there must be a trick in there"... and after a bit of reading went against my initial conclusion...

Doh!!

Good lesson though... trust yourself!


_____________________________________________________________________
"The difficult tasks we do immediately, the impossible takes a little longer"
Post #937324
Posted Tuesday, June 15, 2010 5:14 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, February 4, 2013 1:16 PM
Points: 47, Visits: 34
Thanx a lot
everyday I learn from you new things...
Post #937388
Posted Tuesday, June 15, 2010 6:59 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 1:37 PM
Points: 2,677, Visits: 215
Yep, it only does an RTRIM, not an LTRIM.
Post #937453
Posted Tuesday, June 15, 2010 7:37 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, April 25, 2014 8:31 AM
Points: 513, Visits: 430
crussell-931424 (6/15/2010)
Yep, it only does an RTRIM, not an LTRIM.
This variation to the question may have been a better teaser
Post #937496
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse