May 14, 2012

sp_MSget_attach_state (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_MSget_attach_state(nvarchar @publisher
, nvarchar @publisher_db
, nvarchar @publication
, int @subscription_type)

MetaData:

   
-- This proc is called by distribution agent.
create procedure sys.sp_MSget_attach_state
@publisher sysname, -- publishing server name
@publisher_db sysname, -- publishing database name. If NULL then same as current db
@publication sysname, -- publication name,
@subscription_type int
AS
set nocount on
declare @retcode int

-- Security Check
-- We only run on subscriber so we only need sysadmin and dbo
exec @retcode = sys.sp_MSreplcheck_subscribe
if @@error <> 0 or @retcode <> 0
begin
return (1)
end

-- For non independent agent publications
if @publication is null or @publication = ''
set @publication = 'ALL'

select attach_state, attach_version from MSsubscription_agents
where UPPER(publisher) = UPPER(@publisher)
and publisher_db = @publisher_db
and publication = @publication
and subscription_type = @subscription_type

No comments:

Post a Comment

Total Pageviews