d是主键 是autoid的话就不用管 但要是象单据号那样的话 等先获得最大单据流水线号 再增一 然后将记录insert into 表
declare @tb table(a int,b char(10),c char(10)) declare @max int select @max = isnull(max(a),0) from @tb set @max = @max + 1 insert into @tb (a,b,c) values (@max,'a','b')select * from @tb/*a b c ----------- ---------- ---------- 1 a b (所影响的行数为 1 行)*/
但要是象单据号那样的话 等先获得最大单据流水线号 再增一
然后将记录insert into 表
declare @max int
select @max = isnull(max(a),0) from @tb
set @max = @max + 1
insert into @tb (a,b,c) values (@max,'a','b')select * from @tb/*a b c
----------- ---------- ----------
1 a b (所影响的行数为 1 行)*/