May 21, 2012

sp_MSissnapshotitemapplied (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_MSissnapshotitemapplied(nvarchar @snapshot_session_token
, nvarchar @snapshot_progress_token)

MetaData:

 --   
-- Name: sp_MSissnapshotitemapplied
--
-- Description: This procedure is used by the distribution and the merge
-- agent to determine if a particular snapshot work item
-- has been applied to the subscriber.
--
-- Notes: This procedure should only be called by the merge agent or the
-- distribution agent at the subscriber database.
--
-- Parameters: @snapshot_session_token nvarchar(260)
-- - A UniCode string that uniquely identifies a snapshot
-- delivery session. For now, this will be the snapshot
-- generation folder of the snapshot being applied.
-- @snapshot_progress_token nvarchar(500)
-- - A UniCode string that uniquely identifies a snapshot
-- work item.
--
-- Returns: 0 - succeeded
-- 1 - failed
--
-- Result: This procedure will always return a result set that includes
-- the following column:
--
-- snapshot_item_applied (int)
-- - 1 if the specified snapshot item is found in
-- MSsnapshotdeliveryprogress
-- - 0 if the specified snapshot item is not found
-- in MSsnapshotdeliveryprogress or
-- MSsnapshotdeliveryprogress simply does not exists.
-- The result set will contain exactly one row.
--
-- Security: Execute permission of this procedure is granted to public;
-- procedural security check will be performed to make sure
-- that the caller is either a db_owner of the current database
-- or a sysadmin.
--
create procedure sys.sp_MSissnapshotitemapplied (
@snapshot_session_token nvarchar(260),
@snapshot_progress_token nvarchar(500)
)
as
begin
set nocount on
declare @retcode int
declare @snapshot_progress_token_hash int
select @retcode = 0

exec @retcode = sys.sp_MSreplcheck_subscribe
if @retcode <> 0 or @@error <> 0
begin
select @retcode = 1
goto FAILURE
end

if object_id('dbo.MSsnapshotdeliveryprogress') is not null
begin
select @snapshot_progress_token_hash =
sys.fn_repl32bitstringhash(@snapshot_progress_token)
if @@error <> 0
begin
select @retcode = 1
goto FAILURE
end
if exists (select * from MSsnapshotdeliveryprogress
where progress_token_hash = @snapshot_progress_token_hash
and progress_token = @snapshot_progress_token
and session_token = @snapshot_session_token)
begin
select 'snapshot_item_applied' = 1
end
else
begin
select 'snapshot_item_applied' = 0
end
if @@error <> 0
begin
select @retcode = 1
goto FAILURE
end
end
else
begin
select 'snapshot_item_applied' = 0
end
if @@error <> 0
begin
select @retcode = 1
goto FAILURE
end
FAILURE:
return @retcode
end

No comments:

Post a Comment

Total Pageviews