回答 共 7 条
关键是生成这么长有啥用,而且你以后能确保这个商品不改类别,不改货商?
家乐福、沃尔码都是8位流水号,方便盘点,我们对客户一般是6位流水号,非常方便,真不知要这么长有啥用,一定要联系你的销售商确认。
根据类别、货商重新生成货号:
declare @old varchar(100),
@iint,
@item_novarchar(400),
@item_classvarchar(400),
@item_sup_no varchar(20)
declare cc cursor read_only for select a.item_no, b.class_data,a.item_sup_no
from t_item_info a,t_item_class b where a.item_class=b.item_class order by a.item_class
open cc
while 1=1
begin
fetch cc into @item_no, @item_class,@item_sup_no
if @@fetch_status <> 0 break
if @item_class <> Isnull(@old,'')
begin
set @i = 1
set @old = @item_class
end
else
begin
set @i = @i + 1
end
update t_item_info set item_subno=left((@item_class+'0000'),4)+right(('0000'+@item_sup_no),2)+right(('0000000'+convert(varchar(100),@i)),7) where item_no = @item_no
end
go
close cc
deallocate cc
select item_subno From t_item_info group by item_subno having count(*)>1
注意:先备份后执行,这个语句是取类别前4位+货商编号后2位+流水号7位,重新生成所有的商品货号,一定要先备份数据库,再在查询分析器中,选择数据库执行。
回答者:李祥等级:问不倒翁时间:2013-05-14 14:38
强大学习了
回答者:xly8989等级:银牌会员时间:2013-05-14 15:36
学习了
回答者:kh359等级:问不倒翁时间:2013-05-14 15:38
不错,留个记录,需要的时候方便学习
回答者:bonchen等级:问不倒翁时间:2013-05-14 21:02
学习了
回答者:JCLH等级:问不倒翁时间:2013-05-15 09:19
学习
回答者:hnaywz等级:钻石会员时间:2013-05-15 09:44
学习了。收藏下
回答者:josense等级:皇冠会员时间:2013-05-16 19:01