June 4, 2012

sp_MSunmarkifneeded (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_MSunmarkifneeded(nvarchar @object
, uniqueidentifier @pubid
, int @pre_command
, nvarchar @publisher
, nvarchar @publisher_db)

MetaData:

 create procedure sys.sp_MSunmarkifneeded(  
@object sysname,
@pubid uniqueidentifier,
@pre_command int = 0,
@publisher sysname,
@publisher_db sysname
)AS
declare @table_in_use int
declare @retcode int

exec @retcode = sys.sp_MSreplcheck_subscribe
if @@error<>0 or @retcode<>0
return (1)

select @table_in_use = 0
-- if pre-creation_command is 'drop (1)' or 'truncate (3)', then disallow this deployment if there is already an article using that table.
-- other commands like 'delete, truncate, none are fine'

if exists (select * from dbo.sysmergearticles where objid=object_id(@object) and pubid in
(select pubid from dbo.sysmergepublications where LOWER(publisher)=LOWER(@publisher) and
publisher_db=@publisher_db and pubid<>@pubid))
OR
((@pre_command=1 or @pre_command=3) and
EXISTS (select * from dbo.sysmergearticles where objid=object_id(@object) and pubid <> @pubid and pubid not in
(select pubid from dbo.sysmergepublications where LOWER(publisher)=LOWER(publishingservername()) and publisher_db=db_name())))
begin
select @table_in_use = 1
select @table_in_use
return (0)
end
exec @retcode = sys.sp_MSunmarkreplinfo @object=@object
if @retcode <>0 or @@error<>0
return (1)
select @table_in_use
return (0)

No comments:

Post a Comment

Total Pageviews