问题描述
我想在我的 SQL 值中从左边修剪字符:
I want to trim the characters from the left in my SQL value:
我有以下价值:
ABC0005953
如何从左边修剪 3 个字符的值?我想看:
How do i trim the value 3 characters from the left? I would like to see:
005953
编辑我的值是:
SELECT LEN(TABLE.VALUE)-3)
推荐答案
SELECT SUBSTRING('ABC0005953', 4, LEN('ABC0005953'))
从第四个字符开始并继续.
Start at the fourth character and keep going.
(只是发布作为 RIGHT(...)
解决方案的替代方案.)
(Just posting as an alternative to the RIGHT(...)
solution.)
为了回应您的更新,我假设您的意思是您想将上述内容应用于您的表格:
In response to your update, I assume you mean you want to apply the above to your table:
SELECT SUBSTRING(TABLE.VALUE, 4, LEN(TABLE.VALUE))
FROM TABLE
来自您的另一个问题:
我有以下几点:
选择不同
左(GIFTHEADER.pID + GIFTHEADER.PID + '-' + Cast(PAYMENTDETAIL.PLINENO as Varchar),18)
Left(GIFTHEADER.pID + GIFTHEADER.PID + '-' + Cast(PAYMENTDETAIL.PLINENO as Varchar),18)
作为交易参考...
目前我的价值是这样的:
Currently my value looks like this:
ABC0005953ABC0005953
ABC0005953ABC0005953
我想简单地从 GIFTHEADER.pID 中去掉前 4 个字符
I want to simply strip off the first 4 characters from GIFTHEADER.pID
如果您想从 GIFTHEADER.pID
中删除前四个字符,我建议在将值放入组合字符串之前删除它们:
If you want to remove the first four characters from GIFTHEADER.pID
, I would recommend removing them before putting the value into your combined string:
SELECT DISTINCT
LEFT(SUBSTRING(GIFTHEADER.pID, 5, LEN(GIFTHEADER.pID) +
GIFTHEADER.PID +
'-' +
Cast(PAYMENTDETAIL.PLINENO as Varchar),18)
AS TRANSACTIONREF
这篇关于使用 SQL 从左侧修剪值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!