SELECT RIGHT(MyColumn, LEN(MyColumn) - 4) AS MyTrimmedColumn
Edit: To explain, RIGHT takes 2 arguments β the row (or column) to work and the number of characters returned (starting from the βrightβ row). LEN returns the length of the column data, and we subtract four so that our RIGHT function leaves the leftmost 4 characters βbehindβ.
Hope this makes sense.
Change again - I just read Andrew's answer, and he may very well intervene correctly, and I could be wrong. If this is the case (and you want to UPDATE the table, and not just return the results obtained using the method), you can do this:
UPDATE MyTable SET MyColumn = RIGHT(MyColumn, LEN(MyColumn) - 4)
He is on the right track, but his solution will contain 4 characters at the beginning of the line, instead of dropping the specified 4 characters.
Aaron Alton Jun 11 '09 at 18:29 2009-06-11 18:29
source share