May 8, 2012

sp_MScheck_pub_identity (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_MScheck_pub_identity(nvarchar @publisher
, nvarchar @publisher_db
, nvarchar @tablename)

MetaData:

 CREATE PROCEDURE sys.sp_MScheck_pub_identity   
(
@publisher sysname,
@publisher_db sysname,
@tablename sysname,
@current_max bigint = NULL OUTPUT,
@pub_range bigint = NULL OUTPUT,
@threshold int = NULL OUTPUT,
@range bigint = NULL OUTPUT,
@next_seed bigint = NULL OUTPUT,
@max_identity bigint = NULL OUTPUT
)
AS
begin
declare @retcode int

--
-- security check
-- only db_owner can execute this
--
if (is_member ('db_owner') != 1)
begin
raiserror(14260, 16, -1)
return (1)
end

if @current_max is not NULL
begin
select @current_max=current_max from MSrepl_identity_range
where tablename=@tablename and LOWER(publisher)=LOWER(@publisher) and publisher_db=@publisher_db
if @@ERROR<>0
return (1)
end

if @max_identity is not NULL
begin
select @max_identity=max_identity from MSrepl_identity_range
where tablename=@tablename and LOWER(publisher)=LOWER(@publisher) and publisher_db=@publisher_db
if @@ERROR<>0
return (1)
end

if @pub_range is not NULL
begin
select @pub_range=pub_range from MSrepl_identity_range
where tablename=@tablename and LOWER(publisher)=LOWER(@publisher) and publisher_db=@publisher_db
if @@ERROR<>0
return (1)
end

if @threshold is not NULL
begin
select @threshold=threshold from MSrepl_identity_range
where tablename=@tablename and LOWER(publisher)=LOWER(@publisher) and publisher_db=@publisher_db
if @@ERROR<>0
return (1)
end
if @next_seed is not NULL
begin
select @next_seed=next_seed from MSrepl_identity_range
where tablename=@tablename and LOWER(publisher)=LOWER(@publisher) and publisher_db=@publisher_db
if @@ERROR<>0
return (1)
end
if @range is not NULL
begin
select @range=range from MSrepl_identity_range
where tablename=@tablename and LOWER(publisher)=LOWER(@publisher) and publisher_db=@publisher_db
if @@ERROR<>0
return (1)
end

return (0)
end

No comments:

Post a Comment

Total Pageviews