sys.sp_cdc_generate_wrapper_function (Transact-SQL)sys.sp_cdc_generate_wrapper_function (Transact-SQL)

適用於: 是SQL Server (從 2008 開始) 否Azure SQL Database 否Azure SQL 資料倉儲 否平行處理資料倉儲 APPLIES TO: yesSQL Server (starting with 2008) noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

針對可在 [SQL Server]SQL Server 中使用的異動資料擷取查詢函數產生可建立包裝函數的指令碼。Generates scripts to create wrapper functions for the change data capture query functions that are available in [SQL Server]SQL Server. 產生之包裝函數所支援的 API 可讓您將查詢間隔指定為日期時間間隔。The API that is supported in the generated wrappers enables the query interval to be specified as a datetime interval. 這樣可讓此函數方便用於許多倉儲應用程式中,包括由使用異動資料擷取技術來判斷累加式載入之 Integration ServicesIntegration Services 封裝設計師所開發的應用程式。This makes the function good for use in many warehousing applications, including those that are developed by Integration ServicesIntegration Services package designers who are using change data capture technology to determine incremental load.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions


    [ [ @capture_instance sysname = ] 'capture_instance'  
    [ , [ @closed_high_end_point = ] closed_high_end_pt  
    [ , [ @column_list = ] 'column_list'  
[ , [ @update_flag_list = ] 'update_flag_list'  


[ @capture_instance=] 'capture_instance'[ @capture_instance= ] 'capture_instance'
這是即將產生指令碼的擷取執行個體。Is the capture instance that scripts are to be generated for. capture_instancesysname且具有預設值是 NULL。capture_instance is sysname and has a default value of NULL. 如果您省略了此值或將它明確設定為 NULL,系統就會針對所有擷取執行個體產生包裝函數指令碼。If a value is omitted or explicitly set to NULL, wrapper scripts are generated for all capture instances

[ @closed_high_end_point=] high_end_pt_flag[ @closed_high_end_point= ] high_end_pt_flag
這是旗標位元,它會指出認可時間等於高端點的變更是否要由產生的程序包含在擷取間隔中。Is the flag bit that indicates whether changes that have a commit time equal to the high endpoint are to be included within the extraction interval by the generated procedure. high_end_pt_flag和其預設值為 1,表示應該包含端點。high_end_pt_flag is bit and has a default value of 1, which indicates that the endpoint should be included. 值為 0 表示所有認可時間都將確實小於高端點。A value of 0 indicates that all commit times will be strictly less than the high endpoint.

[ @column_list=] 'column_list'[ @column_list= ] 'column_list'
這是即將包含在包裝函數所傳回之結果集中的已擷取資料行清單。Is a list of captured columns to be included in the result set that is returned by the wrapper function. column_listnvarchar (max) 且具有預設值是 NULL。column_list is nvarchar(max) and has a default value of NULL. 當您指定了 NULL 時,就會包含所有已擷取的資料行。When NULL is specified, all captured columns are included.

[ @update_flag_list=] 'update_flag_list'[ @update_flag_list= ] 'update_flag_list'
這是更新旗標包含在包裝函數所傳回之結果集中的已包含資料行清單。Is a list of included columns for which an update flag is included in the result set that is returned by the wrapper function. update_flag_listnvarchar (max) 且具有預設值是 NULL。update_flag_list is nvarchar(max) and has a default value of NULL. 當您指定了 NULL 時,就不會包含任何更新旗標。When NULL is specified, no update flags are included.

傳回碼值Return Code Values

0 (成功) 或 1 (失敗)0 (success) or 1 (failure)

結果集Result Sets

資料行名稱Column name 資料行類型Column type 描述Description
function_namefunction_name nvarchar(145)nvarchar(145) 產生之函數的名稱。Name of the generated function.
create_scriptcreate_script nvarchar(max)nvarchar(max) 這是建立擷取執行個體包裝函數的指令碼。Is the script that creates the capture-instance wrapper function.


系統一定會產生建立函數來包裝擷取執行個體之所有變更查詢的指令碼。The script that creates the function to wrap the all-changes query for a capture instance is always generated. 如果擷取執行個體支援淨變更查詢,就會一併產生針對此查詢產生包裝函數的指令碼。If the capture instance supports net-changes queries, the script to generate a wrapper for this query is also generatedl.


下列範例將示範如何使用 sys.sp_cdc_generate_wrapper_function,針對所有異動資料擷取函數建立包裝函數。The following example show how you can use sys.sp_cdc_generate_wrapper_function to create wrappers for all the change data capture functions.

DECLARE @wrapper_functions TABLE (  
    function_name sysname,  
    create_script nvarchar(max));  
INSERT INTO @wrapper_functions  
EXEC sys.sp_cdc_generate_wrapper_function;  
DECLARE @create_script nvarchar(max);  
DECLARE #hfunctions CURSOR LOCAL fast_forward  
    SELECT create_script FROM @wrapper_functions;  
OPEN #hfunctions;  
FETCH #hfunctions INTO @create_script;  
WHILE (@@fetch_status <> -1)  
    EXEC sp_executesql @create_script  
    FETCH #hfunctions INTO @create_script  
CLOSE #hfunctions;  
DEALLOCATE #hfunctions;  

另請參閱See Also

異動資料擷取預存程序 (Transact-SQL) Change Data Capture Stored Procedures (Transact-SQL)
異動資料擷取(SSIS)Change Data Capture (SSIS)