June 7, 2012

sp_registercustomresolver (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_registercustomresolver(nvarchar @article_resolver
, nvarchar @resolver_clsid
, nvarchar @is_dotnet_assembly
, nvarchar @dotnet_assembly_name
, nvarchar @dotnet_class_name)

MetaData:

 --   
-- Name: sp_registercustomresolver
--
-- Description: This procedure registers custom resolvers into the MSmerge_articleresolver table in the distribution database
-- This proc should be called in the context of the distribution database
--
-- Parameters:
-- 1. @article_resolver nvarchar(255)
-- This parameter contains the friendly name of the custom resolver or business logic handler
-- 2. @resolver_clsid nvarchar(50),
-- This parameter must be set to a valid CLSID if registering a COM resolver and to NULL while registering a .NET Framework Assembly
-- 3. @is_dotnet_assembly nvarchar(10)
-- This parameter must be set to TRUE while registering a .NET Framework Assembly and false otherwise
-- 4. @dotnet_assembly_name nvarchar(255)
-- For business logic handlers which are .NET assemblies, this parameter either contains the name of the .NET Assembly such as
-- "Sample Business Logic Module For Shippers.dll" if the .NET assembly is deployed into the same directory as the
-- merge agent. Optionally a fully qualified name such as 'C:\Assemblies\COM\Resources\Sample Business Logic Module For Shippers.dll'
-- must be provided that allows the merge agent to load the .NET assembly using the fully qualified path name.
-- 5. @dotnet_class_name nvarchar(255)
-- For business logic handlers which are .NET assemblies, this parameter either contains the name of the .NET class that implements
-- the BusinessLogicModule class such as "Microsoft.Samples.SqlServer.Replication.BusinessLogicHandler.OrderEntryBusinessLogicHandler"
--
--
create procedure sys.sp_registercustomresolver
@article_resolver nvarchar(255),
@resolver_clsid nvarchar(50) = NULL, -- This must be set to a valid CLSID if registering a COM resolver and to NULL for a .NET Framework Assembly
@is_dotnet_assembly nvarchar(10) = 'false', -- This flag must be set to TRUE while registering a .NET Framework Assembly
@dotnet_assembly_name nvarchar(255) = NULL, -- For .NET Framework Assemblies, this parameter must be set to the name of the .NET assembly that implements the BusinessLogicModule class
@dotnet_class_name nvarchar(255) = NULL -- For .NET Framework Assemblies, this parameter must be set to the name of the .NET class that implements the BusinessLogicModule class

AS

declare @retcode int

exec @retcode = sys.sp_MSreplcheck_publish
if (@retcode <> 0 or @@error <> 0)
return 1

if @article_resolver IS NULL or @article_resolver = ''
begin
RAISERROR (21717, 16, -1)
return 1
end

if LOWER(@is_dotnet_assembly collate SQL_Latin1_General_CP1_CS_AS) NOT IN ('true', 'false')
BEGIN
RAISERROR (14137, 16, -1)
return 1
END

if LOWER(@is_dotnet_assembly collate SQL_Latin1_General_CP1_CS_AS) = 'true'
begin
if @resolver_clsid IS NOT NULL
begin
RAISERROR (21807, 16, -1)
return 1
end
if @dotnet_assembly_name IS NULL or @dotnet_assembly_name = ''
begin
RAISERROR (21856, 16, -1, @article_resolver)
return 1
end
if @dotnet_class_name IS NULL or @dotnet_class_name = ''
begin
RAISERROR (21808, 16, -1, @article_resolver)
return 1
end
set @resolver_clsid = '00000000-0000-0000-0000-000000000000'
end
else
begin
if @resolver_clsid IS NULL or @resolver_clsid = ''
begin
RAISERROR (21718, 16, -1)
return 1
end
end

-- this proc can only execute in the distribution database context
if object_id (N'MSmerge_articleresolver') is null
begin
raiserror(25026, 16, -1)
return 1
end


-- Insert a new row into MSmerge_articleresolver if the resolver does not exist, otherwise, update it.
if LOWER(@is_dotnet_assembly collate SQL_Latin1_General_CP1_CS_AS) = 'true'
begin
-- in the case when the resolver is a .NET resolver
if not exists( select * from dbo.MSmerge_articleresolver where article_resolver = @article_resolver)
insert into dbo.MSmerge_articleresolver( article_resolver, resolver_clsid, is_dotnet_assembly, dotnet_assembly_name, dotnet_class_name)
values( @article_resolver, @resolver_clsid, 1, @dotnet_assembly_name, @dotnet_class_name)
else
update dbo.MSmerge_articleresolver
set resolver_clsid = @resolver_clsid,
is_dotnet_assembly = 1,
dotnet_assembly_name = @dotnet_assembly_name,
dotnet_class_name = @dotnet_class_name
where article_resolver = @article_resolver

end
else
begin
-- in the case when the resolver is not a .NET resolver
if not exists( select * from dbo.MSmerge_articleresolver where article_resolver = @article_resolver)
insert into dbo.MSmerge_articleresolver( article_resolver, resolver_clsid, is_dotnet_assembly, dotnet_assembly_name, dotnet_class_name)
values( @article_resolver, @resolver_clsid, 0, NULL, NULL)
else
update dbo.MSmerge_articleresolver
set resolver_clsid = @resolver_clsid,
is_dotnet_assembly = 0,
dotnet_assembly_name = NULL,
dotnet_class_name = NULL
where article_resolver = @article_resolver
end

return @retcode

No comments:

Post a Comment

Total Pageviews