SQL 服务器 - 从位置到字符串末尾的子字符串

SQL Server - substring from position to end of string

我必须拆分一个字符串,我需要取前 25 个字符,然后是其他字符,这是我的代码

select  
    SUBSTRING(field, 1, 25),
    SUBSTRING(field, 26, (LEN(field)-25))
from table

但我得到的是第二个子字符串:

Invalid length parameter passed to the left or substring function

这有什么问题吗?

您可以使用 stuff():

select left(field, 25),
       stuff(field, 1, 25, '')

问题是 substring() 不接受您的代码计算的负长度。