May 7, 2012

sp_MSchange_subscription_dts_info (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_MSchange_subscription_dts_info(varbinary @job_id
, nvarchar @dts_package_name
, nvarchar @dts_package_password
, int @dts_package_location
, bit @change_password)

MetaData:

 CREATE PROCEDURE sys.sp_MSchange_subscription_dts_info   
(
@job_id varbinary(16),
@dts_package_name sysname,
@dts_package_password nvarchar(524),
@dts_package_location int,
@change_password bit
)
AS
begin
--
-- Declarations.
--
declare @subscriber sysname
declare @publisher sysname
declare @subscriber_id smallint
declare @publisher_id smallint

--
-- 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_MSchange_subscription_dts_info', 'distribution')
return (1)
end
--
-- Initializations.
--
SET NOCOUNT ON

select @subscriber_id = subscriber_id, @publisher_id = publisher_id
from MSdistribution_agents where
job_id = @job_id

select @subscriber = srvname from master.dbo.sysservers where srvid = @subscriber_id
select @publisher = srvname from master.dbo.sysservers where srvid = @publisher_id

declare @oledb_subscriber tinyint
select @oledb_subscriber = 3

-- Only SQL Server and OLEDB subscriber support dts
if not exists (select * from MSsubscriber_info where
UPPER(publisher) = UPPER(@publisher) and
UPPER(subscriber) = UPPER(@subscriber) and
(type = 0 or type = @oledb_subscriber))
begin
raiserror(21170, 16, -1)
return 1
end


update MSdistribution_agents set
dts_package_name = case
when @dts_package_name is null then dts_package_name
when @dts_package_name = N'' then null
else @dts_package_name
end,
dts_package_password = case @change_password
when 0 then dts_package_password
else @dts_package_password
end,
dts_package_location = case
when @dts_package_location is null then dts_package_location
else @dts_package_location
end
where
job_id = @job_id

RETURN (0)
end

No comments:

Post a Comment

Total Pageviews