码迷,mamicode.com
首页 > 数据库 > 详细

SSISDB3:Environment

时间:2016-05-14 20:10:22      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:

Environment 是ETL执行时使用的Parameters的集合,可以为一个Project引用不同的Environment variables,从而改变ETL执行的属性。

查看Environments,如图

技术分享

 

1,Create Environment

EXEC [SSISDB].[catalog].[create_environment] 
    @environment_name=NWeekDay, 
    @environment_description=N‘‘, 
    @folder_name=NDemo

GO


2,在环境中创建变量

DECLARE @var sql_variant = N"first"
EXEC [SSISDB].[catalog].[create_environment_variable] 
    @variable_name=NVarEnv, 
    @sensitive=False, 
    @description=N‘‘, 
    @environment_name=NWeekDay, 
    @folder_name=NDemo, 
    @value=@var, 
    @data_type=NString
GO


3,将项目配置为引用Environment

右击ProjectName,点击Configure,在Parameters Tab中查看project的Parameters。

技术分享

点击References Tab,设置project 引用Environment。

技术分享

Declare @reference_id bigint
EXEC [SSISDB].[catalog].[create_environment_reference] 
    @environment_name=NWeekDay, 
    @environment_folder_name=NDemo, 
    @reference_id=@reference_id OUTPUT, 
    @project_name=NISStudy, 
    @folder_name=NDemo, 
    @reference_type=A
Select @reference_id

GO

回到Parameters Tab,点击value column后面的ellipsis 设置project Variables引用 Environment variables。

技术分享

EXEC [SSISDB].[catalog].[set_object_parameter_value] 
    @object_type=20, 
    @parameter_name=NVarEnv, 
    @object_name=NISStudy, 
    @folder_name=NDemo, 
    @project_name=NISStudy, 
    @value_type=R, 
    @parameter_value=NVarEnv
GO


参数 @value_type ,参数值=R,表明参数值是一个引用值,且正在使用一个Environment Variable;参数值=V,表示参数是一个文本值

 

通过 catalog.environment_references 查看Reference

reference_type: Indicates whether the environment can be located in the same folder as the project (relative reference) or in a different folder (absolute reference). When the value is R, the environment is located by using a relative reference. When the value is A, the environment is located by using an absolute reference.

技术分享

A project can have relative or absolute environment references. Relative references refer to the environment by name and require that it resides in the same folder as the project. Absolute references refer to the environment by name and folder, and may refer to environments that reside in a different folder than the project. A project can reference multiple environments.

 

技术分享

对于Demo这个folder来说,LocalFolder下的Environment 是Relative Environment,在Demo下的Environment 是absolute Environment。

 

参考MSDN:catalog.environment_references (SSISDB Database)

4,执行Package,引用Environment Variable,在 [catalog].[create_execution] 的参数 @reference_id中设置引用对象

Declare @execution_id bigint
EXEC [SSISDB].[catalog].[create_execution] 
    @package_name=NPackage.dtsx, 
    @execution_id=@execution_id OUTPUT, 
    @folder_name=NDemo, 
    @project_name=NISStudy, 
    @use32bitruntime=False, 
    @reference_id=1

Select @execution_id


DECLARE @var0 smallint = 1
EXEC [SSISDB].[catalog].[set_execution_parameter_value] 
        @execution_id,  
        @object_type=50, 
        @parameter_name=NLOGGING_LEVEL, 
        @parameter_value=@var0

EXEC [SSISDB].[catalog].[start_execution] @execution_id
GO


 

SSISDB3:Environment

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/4954351.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!