SQL Server 2016 函数:SUBSTRING

2018-06-03  本文已影响82人  江湖十年
SUBTRING(expression,start,length);
SELECT SUBSTRING('aabbcc',3,2);

SELECT SUBSTRING('aabbcc',3,LEN('aabbcc'));

SELECT SUBSTRING('aabbcc',3,100);  -- 截取超过字符串长度不会报错,返回从截取起始位置到最后的字符串
image.png
SELECT * FROM Subject WHERE ID=4;

SELECT SUBSTRING(Description,3,6) AS New_Description FROM Subject WHERE ID=4;

SELECT SUBSTRING(Description,3,100) AS New_Description FROM Subject WHERE ID=4;
image.png
上一篇下一篇

猜你喜欢

热点阅读