May 10, 2012

sp_MSdrop_snapshot_dirs (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_MSdrop_snapshot_dirs()

MetaData:

 CREATE PROCEDURE sys.sp_MSdrop_snapshot_dirs  
as
begin
declare @retcode int
declare @snapshot_bit int
declare @directory_type int
declare @alt_directory_type int
declare @publisher_database_id int

declare @dir nvarchar(512)
declare @command_id int
declare @xact_seqno varbinary(16)

select @snapshot_bit = 0x80000000
select @directory_type = 7
select @alt_directory_type = 25

-- Sysadmin check
if (isnull(is_srvrolemember('sysadmin'),0) = 0)
begin
raiserror(14260, 16, -1)
return (1)
end

--
-- security check
-- sysadmin check is done in sp_MSreplremoveuncdir
--
declare hCdirs CURSOR LOCAL FAST_FORWARD FOR select CONVERT(nvarchar(512), command),
xact_seqno, command_id, publisher_database_id
from MSrepl_commands where
((type & ~@snapshot_bit) = @directory_type) or
((type & ~@snapshot_bit) = @alt_directory_type)
for read only

open hCdirs
fetch hCdirs into @dir, @xact_seqno, @command_id, @publisher_database_id
while (@@fetch_status <> -1)
begin
--
-- Need to map unc to local drive for access problem
-- Security check is done in sp_MSreplremoveuncdir
--
exec @retcode = sys.sp_MSreplremoveuncdir @dir
-- Abort the operation if the delete fails --
if (@retcode <> 0 or @@error <> 0)
return (1)

delete MSrepl_commands where
publisher_database_id = @publisher_database_id and
xact_seqno = @xact_seqno and
command_id = @command_id

fetch hCdirs into @dir, @xact_seqno, @command_id, @publisher_database_id
end
close hCdirs
deallocate hCdirs
end

No comments:

Post a Comment

Total Pageviews