April 25, 2012

sp_getsubscriptiondtspackagename (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_getsubscriptiondtspackagename(nvarchar @publication
, nvarchar @subscriber)

MetaData:

 create procedure sys.sp_getsubscriptiondtspackagename (  
@publication sysname,
@subscriber sysname = NULL
) AS

SET NOCOUNT ON

declare @name sysname
declare @name_full sysname
declare @id int
declare @retcode int

--
-- Security Check
--
EXEC @retcode = sys.sp_MSreplcheck_publish
IF @@ERROR <> 0 or @retcode <> 0
return (1)

select @id = 1
select @name = @publication
if @subscriber is not null
select @name = @name + N'_' + @subscriber

-- reserver space for numbers to make the name unique
select @name = substring(@name, 1, 100)
select @name_full = @name

while (1=1)
begin
if not exists (select * from msdb.dbo.sysdtspackages where
name = @name_full)
break
select @name_full = @name + '_' + convert(nvarchar(10), @id)
select @id = @id + 1
end
select N'new_package_name' = @name_full

No comments:

Post a Comment

Total Pageviews