怎么实现?货号自动生成规则:4位类别、2位货商、7位流水号
- 提问者: 666666
- 等级:普通会员
- 时间:2013-05-14 12:36
- 悬赏:0
- 解决时间:2013-05-24 12:36
回答 共 7 条
关键是生成这么长有啥用,而且你以后能确保这个商品不改类别,不改货商?
家乐福、沃尔码都是8位流水号,方便盘点,我们对客户一般是6位流水号,非常方便,真不知要这么长有啥用,一定要联系你的销售商确认。
根据类别、货商重新生成货号:
declare @old varchar(100),
@i int,
@item_no varchar(400),
@item_class varchar(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位,重新生成所有的商品货号,一定要先备份数据库,再在查询分析器中,选择数据库执行。
家乐福、沃尔码都是8位流水号,方便盘点,我们对客户一般是6位流水号,非常方便,真不知要这么长有啥用,一定要联系你的销售商确认。
根据类别、货商重新生成货号:
declare @old varchar(100),
@i int,
@item_no varchar(400),
@item_class varchar(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
快到期问题