May 7, 2012

sp_MSadjust_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_MSadjust_pub_identity(nvarchar @publisher
, nvarchar @publisher_db
, nvarchar @tablename
, bigint @current_max
, int @threshold
, bigint @range
, bigint @next_seed
, bigint @pub_range)

MetaData:

 CREATE PROCEDURE sys.sp_MSadjust_pub_identity   
(
@publisher sysname,
@publisher_db sysname,
@tablename sysname,
@current_max bigint = NULL,
@threshold int = NULL,
@range bigint = NULL,
@next_seed bigint = NULL,
@pub_range bigint = NULL
)
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
--
-- security check
-- Has to be executed from distribution database
--
if (sys.fn_MSrepl_isdistdb (db_name()) != 1)
begin
raiserror(21482, 16, -1, 'sp_MSadjust_pub_identity', 'distribution')
return (1)
end
if @current_max is NOT NULL
begin
update MSrepl_identity_range set current_max=@current_max
where tablename=@tablename and LOWER(publisher)=LOWER(@publisher) and publisher_db=@publisher_db
if @@ERROR<>0
return (1)
if exists (select * from MSrepl_identity_range where max_identity is not NULL
and ABS(current_max) > ABS(max_identity))
begin
raiserror(21195, 16, -1)
return (1)
end
end
if @threshold is NOT NULL
begin
update MSrepl_identity_range set threshold=@threshold
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
update MSrepl_identity_range set next_seed=@next_seed
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
update MSrepl_identity_range set range=@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
update MSrepl_identity_range set pub_range=@pub_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