AS
begin
declare @LastID varchar(50)
declare @CreateID varchar(12)
SET LOCK_TIMEOUT 3600
begin TRANSACTION
select @LastID = CreateID from CreateID with (rowlock) where TableName = @TableName
if @@ERROR<>0
begin
ROLLBACK TRANSACTION
set @CreateID=''
RETURN
end
set @CreateID =convert(char(6),getdate(),12)+'000001'
if @LastID is null
begin
set @CreateID=convert(char(6),getdate(),12)+'000001'
insert CreateID (TableName,CreateID) values( @TableName,@CreateID)
end
else
begin
if left(@LastID,6) = convert(char(6),getdate(),12)
begin