--用自定义函数--创建自定义
create function f_nid()
returns char(8)
as
begin
return(right(100000001+isnull((select max(spbh) from kcgl),0),8))
end
go--建表语句改为:
Create table kcgl(
spbh spbh default dbo.f_nid(),
spmc varchar(20) not null,
spgg varchar(20) not null,
splx varchar(20) not null,
pfdj numeric(7,2) not null,
kcsl int default(0) not null)--插入记录时使用:
insert kcgl(spmc,...kcsl) values('ff',...5)