现在可以使用任何长度的前缀和数字部分(每个最多20个)
DECLARE @prefix varchar(20), @numberstr varchar(20), @number int, @Val varchar(40)SELECT @Val = 'ABCD000006'--SELECT @Val = 'A03'SELECT @prefix = LEFt(@Val, PATINDEX ('%[0-9]%', @Val) -1)SELECT @numberstr = SUBSTRINg(@Val, PATINDEX ('%[0-9]%', @Val), 8000)SELECT @number = CAST(@numberstr AS int) + 1SELECT @prefix + RIGHt(REPLACE(SPACe(LEN(@numberstr)), ' ', '0') + CAST(@number AS varchar(20)), LEN(@numberstr))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)