求表设计及查询有关问题

求表设计及查询问题
一种配件的收支存台账

每一件配件都有唯一的编号。

配件的入库一般是成批的,比如:从08758458222001——08758458222199 录入时也是这样从多少编号到多少编号。
配件的出库是10个为一批,比如:从08450——08460 录入到库中的数据也是如此。
编号怎么进行加法运算呀?如果能自动加,那后面的编号就不用输了,可以自动生成。

查找功能:输入编号,可以查到入库和出库的情况(日期,值班人等)。

可能很简单。大家给个思路啊!我是菜鸟!

------解决方案--------------------
自增加一的实现

if object_id( 'pubs..tb ') is not null
drop table tb
go

create table tb
(
id int,
name char(1)
)
insert into tb(id,name) values(1, 'A ')
insert into tb(id,name) values(2, 'B ')
insert into tb(id,name) values(3, 'C ')
go

select id1 = identity(int,1,1) , * into test from tb
select * from test
drop table tb
drop table test

id1 id name
----------- ----------- ----
1 1 A
2 2 B
3 3 C

(所影响的行数为 3 行)

如果ID不重复。还可以用下面的语句。
select id1 = (select count(1) from tb where id <= a.id) , * from tb a
------解决方案--------------------
自增加序号

Id, FormatId, F1 ,F2
Id序号我设了自动加一,FormatId我想他也象这样 "SL000001 ",
当Insert时就加1,FormatId我想他也能自动加一 "SL000001 ", "SL000002 "...
能用一条sql什么办法实现.最好不要用中间表。有什么好方法?
谢谢!


create table #test
(id int identity,
FormatId as 'SL '+right(10000000+id,6),
F1 varchar(50))
go
insert #test(F1) select '1 '
union all select '2 '


select * from #test

drop table #test


/*
id FormatId F1
----------- -------------- -----
1 SL000001 1
2 SL000002 2

(所影响的行数为 2 行)
*/
------解决方案--------------------
没明白是什么意思,想要干什么,表结构是什么样的?


编号怎么进行加法运算呀!可以转换成整形计算,然后再计算的结果中,在右侧不足,少的“0”


------解决方案--------------------
增加一个自动增长列,然后利用它去处理!
------解决方案--------------------
从08758458222001——08758458222199 
看得出前面的数据是变动的,自增加不好搞.

一般可在前台用代码编写完成.