create procedure [sys].[sp_cdc_generate_wrapper_function_internal]
(
@closed_high_end_point bit,
@column_list nvarchar(max),
@update_flag_list nvarchar(max)
)
with execute as 'dbo'
as
begin
set nocount on
declare @object_id int
,@capture_instance sysname
,@function_name nvarchar(145)
,@mapping_option nvarchar(30)
,@create_script nvarchar(max)
,@supports_net_changes bit
declare #hinstance cursor local fast_forward for
select capture_instance, object_id
from #capture_instances
if (@closed_high_end_point = 1)
set @mapping_option = N'largest less than or equal'
else
set @mapping_option = N'largest less than'
open #hinstance
fetch #hinstance into @capture_instance, @object_id
while (@@fetch_status <> -1)
begin
-- Generate the script to create a wrapper for the all changes function
set @function_name = N'fn_all_changes_' + @capture_instance
exec sys.sp_cdc_create_change_enumeration_wrapper_function @capture_instance,
@function_name, @mapping_option, @column_list, @update_flag_list, @create_script OUTPUT
insert into #create_scripts values(@function_name, @create_script)
-- If the capture instance supports net changes, create a wrapper for the
-- net changes query function
if exists (
select capture_instance from cdc.change_tables
where capture_instance = @capture_instance
and supports_net_changes = 1 )
begin
set @function_name = N'fn_net_changes_' + @capture_instance
exec sys.sp_cdc_create_change_enumeration_wrapper_function @capture_instance,
@function_name, @mapping_option, @column_list, @update_flag_list, @create_script OUTPUT
insert into #create_scripts values(@function_name, @create_script)
end
fetch #hinstance into @capture_instance, @object_id
end
close #hinstance
deallocate #hinstance
return 0
end