SqlServer:处理字符串charindex
Posted zhenghuanhuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SqlServer:处理字符串charindex相关的知识,希望对你有一定的参考价值。
declare @DiscrepancyLoanNos varchar(max)
set @DiscrepancyLoanNos =‘00123,00456,00789’
DECLARE @Loans Table
(
LoanNo varchar(10)
)
WHILE(charindex(‘,‘,@DiscrepancyLoanNos)<>0)
BEGIN
insert @Loans(LoanNo) values (substring(@DiscrepancyLoanNos,1,charindex(‘,‘,@DiscrepancyLoanNos)-1))
set @DiscrepancyLoanNos = stuff(@DiscrepancyLoanNos,1,charindex(‘,‘,@DiscrepancyLoanNos),‘‘)
END
INSERT INTO @Loans(LoanNo) values (@DiscrepancyLoanNos)
select * from @Loans
结果:
00123
00456
00789
以上是关于SqlServer:处理字符串charindex的主要内容,如果未能解决你的问题,请参考以下文章