Rick Romack (9/10/2009)
I do disagree with this answer,If I run
DECLARE @STR NVARCHAR(10)
SET @STR = '1, 2, 3, '
SET @STR = LEFT(@str, LEN(@str)- 2)
select len(@str)
SELECT @STR
The return for len(@str) returns 5 that would be '1, 2,' with no space after the comma.
If I copy the result of the SELECT @STR to word and have it show all characters there is no space after the comma.
I was about to say I agree with you Rick and I actually did until......
DECLARE @STR NVARCHAR(10)
SET @STR = '1, 2, 3, '
SET @STR = LEFT(@str, LEN(@str)- 2)
select '"'+@str+'"' mystr, len(@str) lenstr
The result as copied from sql server 2005 and 2008. Both gave the same results.
mystrlenstr
"1, 2, "5
When I pasted the result in here directly from ssms I saw that there was actually a space at the end but what stumps me is the fact that it gave a LEN of 5 characters and that does not include the space at the end. Can someone please clear this for me 'cause I am stumped.
:-PManie Verster
Developer
Johannesburg
South Africa
I can do all things through Christ who strengthens me. - Holy Bible
I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)