June 6, 2012

sp_MSuploadsupportabilitydata (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


sys.sp_MSuploadsupportabilitydata(nvarchar @publisher
, nvarchar @publisher_db
, nvarchar @publication
, nvarchar @server_name
, nvarchar @db_name
, nvarchar @file_name
, int @log_file_type
, varbinary @log_file
, nvarchar @web_server
, int @compatlevel)


create procedure sys.sp_MSuploadsupportabilitydata
(@publisher sysname,
@publisher_db sysname,
@publication sysname,
@server_name sysname = NULL, -- Replica or subscriber Server Name --
@db_name sysname = NULL, -- Replica or subscriber Database Name --
@file_name nvarchar(2000), -- data for the log file --
@log_file_type int,
@log_file varbinary(max) = NULL, -- data for the log file --
@web_server sysname = NULL, -- name of the IIS server --
@compatlevel int = 90) -- backward compatibility level, default=Sphinx

declare @retcode int
declare @subid uniqueidentifier
declare @pubid uniqueidentifier
declare @upload_time datetime

select @publisher_db = RTRIM(@publisher_db)
select @db_name = RTRIM(@db_name)

-- Security Check and publication validation
exec @retcode = sys.sp_MSmerge_validate_publication_presence @publication, @publisher_db, @publisher, @pubid output
if @retcode <> 0 or @@error <> 0
return 1

if (@server_name is NULL)
SET @server_name = publishingservername()

if (@db_name is NULL)
set @db_name = db_name()

SELECT @subid = subid
FROM dbo.sysmergesubscriptions
WHERE UPPER(subscriber_server) collate database_default = UPPER(@server_name) collate database_default
and db_name = @db_name and pubid = @pubid

if @subid is NULL
RAISERROR(20021, 16, -1)
return (1)

select @upload_time = getdate()

-- Insert the log data into the MSmerge_log_files table
insert into dbo.MSmerge_log_files (pubid, subid, web_server, file_name, upload_time, log_file_type, log_file)
values (@pubid, @subid, @web_server, @file_name, @upload_time, @log_file_type, @log_file)

if @@error <> 0
return 1

update dbo.MSmerge_supportability_settings
set last_log_upload_time = @upload_time
WHERE pubid = @pubid and subid = @subid and
((@web_server IS NULL and web_server IS NULL) or (@web_server IS NOT NULL and
UPPER(web_server) collate database_default = UPPER(@web_server) collate database_default ))

if @@error <> 0
return 1

return (0)

No comments:

Post a Comment

Total Pageviews