在Sql Server 2012開始,微軟給SSIS添加了Project Model這種新的項目類型,與之對應的是在Sql Server數據庫引擎中引入了Intergration Services Catalog這種新的部署方式。
當你在Sql Server中啟用Intergration Service Catalog后,就會在Intergration Services Catalog下多出一個系統文件夾叫SSISDB,如下圖所示我們已經發布了一個SSIS項目SSIS_LOG_TESTING到子文件夾Demo_Project_Folder下:

而在數據庫中,我們也可以看到Sql Server自動生成了一個名叫SSISDB的數據庫,該數據庫就是用來存儲Intergration Services Catalog下的項目數據的,請不要亂動其中的數據。

用過SSIS Project Model的開發人員應該都知道,這種新的項目類型相比老的Package Model有很多好處,其中一個好處就是可以在項目級別上定義全局參數,SSIS項目中的所有dtsx包都可以訪問項目參數,如下圖所示:

而當項目發布到Intergration Services Catalog后,也可以在Intergration Services Catalog上直接修改這些項目參數的值:


但是隨之而來的問題是,隨着在Intergration Services Catalog部署的SSIS項目越來越多,有沒有什么辦法能過統一管理這些SSIS項目的參數呢?因為Project Model的項目參數有個很大的缺點,那就是沒有辦法將其值存儲在數據庫中,而老的Pakacge Model是可以將SSIS項目中Configuration中的值存儲在數據庫表中的。所以導致了Project Model的項目參數沒法集中管理,設想一下你的Intergration Services Catalog下如果有100個SSIS項目,假如這100項目都有一個同名的項目參數叫UserName,你現在想更改這100個項目的UserName項目參數,你只有手動打開每個項目的配置去設置UserName項目參數,是一件很耗時的操作。
而Intergration Services Catalog生成的數據庫SSISDB中提供了一系列視圖和存儲過程,可以讓我們用Sql語句來操作每個SSIS項目的項目參數,如下圖所示:

其中有一個視圖和存儲過程特別有用,這里列出來:
視圖catalog.object_parameters
該視圖可以返回在Intergration Services Catalog中發布所有SSIS項目的項目參數信息,官方介紹如下:
Displays the parameters for all packages and projects in the Integration Services catalog.
| Column name | Data type | Description |
|---|---|---|
| parameter_id | bigint | The unique identifier (ID) of the parameter. |
| project_id | bigint | The unique ID of the project. |
| object_type | smallint | The type of parameter. The value is 20 for a project parameter and the value is 30 for a package parameter. |
| object_name | sysname | The name of the corresponding project or package. |
| parameter_name | sysname(nvarchar(128)) | The name of the parameter. |
| data_type | nvarchar(128) | The data type of the parameter. |
| required | bit | When the value is 1, the parameter value is required in order to start the execution. When the value is 0, the parameter value is not required to start the execution. |
| sensitive | bit | When the value is 1, the parameter value is sensitive. When the value is 0, the parameter value is not sensitive. |
| description | nvarchar(1024) | An optional description of the package. |
| design_default_value | sql_variant | The default value for the parameter that was assigned during the design of the project or package. |
| default_value | sql_variant | The default value that is currently used on the server. |
| value_type | char(1) | Indicates the type of parameter value. This field displays V when parameter_value is a literal value and R when the value is assigned by referencing an environment variable. |
| value_set | bit | When the value is 1, the parameter value has been assigned. When the value is 0, the parameter value has not been assigned. |
| referenced_variable_name | nvarchar(128) | The name of the environment variable that is assigned to the value of the parameter. The default value is NULL. |
| validation_status | char(1) | Identified for informational purposes only. Not used in SQL Server 2017. |
| last_validation_time | datetimeoffset(7) | Identified for informational purposes only. Not used in SQL Server 2017. |
Permissions
To see rows in this view, you must have one of the following permissions: +
-
READ permission on the project
-
Membership to the ssis_admin database role
-
Membership in the sysadmin server role.
Row-level security is enforced; only rows that you have permission to view are displayed.
該視圖查詢結果截圖如下:

存儲過程catalog.set_object_parameter_value
該存儲過程可以設置在Intergration Services Catalog中部署SSIS項目的項目參數,官方介紹如下:
Sets the value of a parameter in the Integration Services catalog. Associates the value to an environment variable or assigns a literal value that is used by default when no other values are assigned.
Syntax
catalog.set_object_parameter_value [@object_type =] object_type , [@folder_name =] folder_name , [@project_name =] project_name , [@parameter_name =] parameter _name , [@parameter_value =] parameter_value [ , [@object_name =] object_name ] [ , [@value_type =] value_type ]
Arguments
[@object_type =] object_type The type of parameter. Use the value 20 to indicate a project parameter or the value 30 to indicate a package parameter. The object_type is smallInt.
[@folder_name =] folder_name The name of the folder that contains the parameter. The folder_name is nvarchar(128).
[@project_name =] project_name The name of the project that contains the parameter. The project_name is nvarchar(128).
[@parameter_name =] parameter_name The name of the parameter. The parameter_name is nvarchar(128).
[@parameter_value =] parameter_value The value of the parameter. The parameter_value is sql_variant.
[@object_name =] object_name The name of the package. This argument required when the parameter is a package parameter. The object_name is nvarchar(260).
[@value_type =] value_type The type of parameter value. Use the character V to indicate that parameter_value is a literal value that is used by default when no other values are assigned prior to execution. Use the character R to indicate that parameter_value is a referenced value and has been set to the name of an environment variable. This argument is optional, the character V is used by default. The value_type is char(1).
Return Code Value
0 (success)
Result Sets
None
Permissions
This stored procedure requires one of the following permissions:
-
READ and MODIFY permissions on the project
-
Membership to the ssis_admin database role
-
Membership to the sysadmin server role
Errors and Warnings
The following list describes some conditions that may cause the stored procedure to raise an error:
-
The parameter type is not valid
-
The project name is not valid
-
For package parameters, the package name is not valid
-
The value type is not valid
-
The user does not have the appropriate permissions
Remarks
-
If no value_type is specified, a literal value for parameter_value is used by default. When a literal value is used, the value_set in the object_parameters view is set to
1. A NULL parameter value is not allowed. -
If value_type contains the character
R, which denotes a referenced value, parameter_value refers to the name of an environment variable. -
The value
20may be used for object_type to denote a project parameter. In this case, a value for object_name is not necessary, and any value specified for object_name is ignored. This value is used when the user wants to set a project parameter. -
The value
30may be used for object_type to denote a package parameter. In this case, a value for object_name is used to denote the corresponding package. If object_name is not specified, the stored procedure returns an error and terminates.
該存儲過程的執行結果如下:
EXEC catalog.set_object_parameter_value 20,N'Demo_Project_Folder',N'SSIS_LOG_TESTING',N'ProjectVersion',N'2.0.0.0'


