日期:2014-05-17 浏览次数:20371 次
declare @NextIdentity int SELECT @NextIdentity = IDENT_CURRENT('TableName') + IDENT_INCR('TableName') from TableName if (@NextIdentity is null) set @NextIdentity = IDENT_SEED('TableName')
GO /****** Object: StoredProcedure [dbo].[NextIDENT] Script Date: 05/16/2012 12:32:55 ******/ SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER OFF GO ALTER PROCEDURE [dbo].[NextIDENT] ( @tblName varchar(255) -- 表名 ) AS declare @NextIdentity int begin SELECT @NextIdentity = IDENT_CURRENT(@tblName) + IDENT_INCR(@tblName) from bx_Posts if (@NextIdentity is null) set @NextIdentity = IDENT_SEED(@tblName) end exec(@NextIdentity)
SELECT @NextIdentity = IDENT_CURRENT(@tblName) + IDENT_INCR(@tblName) from bx_Posts
GO alter PROCEDURE [dbo].[NextIDENT] ( @tblName varchar(255) -- 表名 ) AS exec(' declare @NextIdentity int SELECT @NextIdentity = IDENT_CURRENT('''+@tblName+''') + IDENT_INCR('''+@tblName+''') from '+@tblName+' if (@NextIdentity is null) begin set @NextIdentity = IDENT_SEED('''+@tblName+''') end select @NextIdentity') Go [NextIDENT] 'Flow_Class'