开发者

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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜