标签:str ble begin sel while string server int 字符
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
标签:str ble begin sel while string server int 字符
原文地址:https://www.cnblogs.com/zhenghuanhuan/p/8890823.html