How do I get the last three digits of a varying length column?
I want to write a select statement and get the last three digits of all of the rows in a column for which the length varies.
Any ideas on how I can achieve this?
Hypothetical column:
12312398098098
127865275
I want t开发者_StackOverflowhe resulting column to have the values: Resulting column after the script:
098
275
SELECT RIGHT(CONVERT(VARCHAR(4000), [hypothetical column]), 3) FROM table;
(Added a convert in case this is a numeric column.)
精彩评论