变量值为何为空?
在此游标中给一字符型变量循环赋值,结果这个变量的值怎么是Null
declare
@Str nvarchar(1000)
declare SerChargeStandard cursor
static
for select convert(nvarchar(18),T_ChargeStandardT.起始价),convert(nvarchar(18),T_ChargeStandardT.终止价),replicate(' ',8-len(convert(nvarchar(18),T_ChargeStandardT.收费标准)))+convert(nvarchar(18),T_ChargeStandardT.收费标准) from T_ChargeStandardT,T_TractBusiness where 起始价<T_TractBusiness.最终成交价 and T_TractBusiness.ID='Shooter2005001' order by T_ChargeStandardT.起始价 desc
declare
@BeginPrice nvarchar(18),
@EndPrice nvarchar(18),
@ChargeStandard nvarchar(18)
open SerChargeStandard
fetch next from SerChargeStandard into @BeginPrice,@EndPrice,@ChargeStandard
while (@@fetch_status=0)
begin
set @Str=@Str+(@BeginPrice+'~'+@EndPrice+' '+@ChargeStandard)+char(10)
fetch next from SerChargeStandard into @BeginPrice,@EndPrice,@ChargeStandard
end
print @Str
close SerChargeStandard
deallocate SerChargeStandard