T-SQL Substring - Last 3 Characters

前端 未结 5 382
野趣味
野趣味 2021-01-31 07:01

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

So the column text is IDS_ENUM_Change_262147_190

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 07:53

    You can use either way:

    SELECT RIGHT(RTRIM(columnName), 3)
    

    OR

    SELECT SUBSTRING(columnName, LEN(columnName)-2, 3)
    

提交回复
热议问题