T-SQL 子字符串 - 最后 3 个字符

问题描述:

使用 T-SQL,我将如何获取 varchar 列的最后 3 个字符?

Using T-SQL, how would I go about getting the last 3 characters of a varchar column?

所以列文本是 IDS_ENUM_Change_262147_190,我需要 190

So the column text is IDS_ENUM_Change_262147_190 and I need 190

SELECT RIGHT(column, 3)

这就是你所需要的.

你也可以用同样的方式做LEFT().

You can also do LEFT() in the same way.

请记住,如果您在 WHERE 子句中使用它,RIGHT() 不能使用任何索引.

Bear in mind if you are using this in a WHERE clause that the RIGHT() can't use any indexes.