需要从 SQL 中的字符串中删除前 11 个字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9114500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:13:42  来源:igfitidea点击:

need to trim first 11 characters off a string in SQL

sqlsql-server

提问by njj56

Is there anyway to trim the first x amount of characters in a varchar? I am unable to do this using the left or right functions a well as other trimming methods. Will be doing this on standard MS-SQL. Thank you.

无论如何要修剪 varchar 中的前 x 个字符?我无法使用 left 或 right 函数以及其他修剪方法来做到这一点。将在标准 MS-SQL 上执行此操作。谢谢你。

回答by Martin Smith

SELECT STUFF(SomeString,1,11,'')

(obligatory link)

强制链接

回答by dasblinkenlight

There are several ways of doing it. One of the simpler ones would be to use RIGHTand LENcombination:

有几种方法可以做到。更简单的方法之一是使用RIGHTLEN组合:

select RIGHT(a.col, LEN(a.col)-11) from MyTable a