变量值为何为空?

GeoPrjLJ 2005-01-28 04:21:27
在此游标中给一字符型变量循环赋值,结果这个变量的值怎么是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
...全文
78 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
GeoPrjLJ 2005-01-28
  • 打赏
  • 举报
回复
果然是没设初值,谢谢!
jinjazz 2005-01-28
  • 打赏
  • 举报
回复
没有指向任何东西
daijingjie2002 2005-01-28
  • 打赏
  • 举报
回复
declare
@Str nvarchar(1000)
select @str=''
Qihua_wu 2005-01-28
  • 打赏
  • 举报
回复
没有设初始值
set @str=''

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧