-
Strange Len function
Why is it so?
select len("Test")
--returns 4
select len("Test ")
--returns 4
select len(" Test ")
--returns 7
why not all 4 ?
why not 4,11,14?
-
I got 4, 4, 5. Seems system ignores trailing blanks.
-
When I run those statements I get different results. (double quotes failed for me).
select len('Test')
--returns 4
select len('Test ')
--returns 4
select len(' Test ')
--returns 5
The reason I get the results I got is because I have ANSI_PADDING turned off.
Sidney Ives
-
I tried with ANSI_PADDING on but still got same result.
-
Works the same for me as well. So much for SQL doc.
Sidney
-
Function LEN in Books Online
LEN
Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks...
... and here is my tip ...
select len('test ')
, len(N'test ')
, datalength('test ')
, datalength(N'test ')/2
--returns 4,4,5,5
YuckFou
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|