Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-02-13 : 11:47:58
|
| Quick question guys:Say I have a varchar(254) field. I'm doing a length check on itlen(myfield). The field generally has a lot of empty space on the right. Which should be faster:len(myfield)len(rtrim(myfield))I'm thinking the first one because the field is a varchar and there really is nothing to the right of the last character.TIA!Michael |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-02-13 : 11:56:43
|
| Well, the first one will be faster regardless, because the Rtrim isn't performed.Varchar shouldn't have any trailing spaces, unless your server has SET ANSI_PADDING ON. That will fill out varchar columns to their maximum length with spaces, as if they were char columns. You might want to check that setting.You could also run a one-time UPDATE statement:UPDATE myTable SET myField=Rtrim(myField)That'll trim all the myField values and then you can just use Len(). |
 |
|
|
|
|
|