在重新排序我的Web项目的过程中,我试图在每个项目序号的末尾附加4个零。我所尝试的一切都不起作用,它似乎会自动删除格式化后的零。这是一个int字段。我到了1项作为测试工作的唯一的东西实际上是做了更换,例如:将尾随零添加到SQL中的int字段中
update sacatalogitem
set itm_seq = replace(itm_seq, '8021', '80210000')
where itm_id = '13' and ctg_id = '917'
我已经使用游标和替换审判和执行这一点:去除结尾零:
declare @SEQ int
declare @ID int
declare @CTG int
declare cur cursor for
select a.itm_seq, a.itm_id, a.ctg_id from sacatalogitem as a
join saitem as b on b.itm_id = a.itm_id
where a.cat_id = '307' and a.itm_id = '13' and a.ctg_id = '917'
open cur
fetch next from cur into @SEQ,@ID,@CTG
While (@@FETCH_STATUS=0)
Begin
Update sacatalogitem
set itm_seq = replace(itm_seq, @SEQ, @SEQ + '0000')
where itm_id = @ID and ctg_id = @CTG
Update saitem
set itm_import_action = 'P'
where itm_id = @ID
fetch next from cur into @SEQ,@ID,@CTG
end
close cur
deallocate cur
这也失败对我来说:
update sacatalogitem
set itm_seq = itm_seq + '0000'
where itm_id = '13' and ctg_id = '917'
任何帮助,将不胜感激这个小令人沮丧的问题。
将你想要什么,如果itm_seq为零( 0或00000)? – hatchet 2014-09-10 23:18:24