Code
CREATE procedure ag_getnewkey @tablename varchar (40), @newkey integer out as set nocount on if (exists (select 1 from as_tablekeys where tablename = upper(@tablename) )) begin select @newkey=maxkey+1 from as_tablekeys where tablename = upper(@tablename) update as_tablekeys set maxkey = @newkey where tablename = upper(@tablename) end else begin insert into as_tablekeys (tablename, maxkey) values (upper(@tablename), 1) set @newkey = 1 end
GO
posted @
2009-06-12 12:49
doing_zzh
阅读(
237)
评论()
编辑
收藏
举报