SELECT objp.[referenced_variable_name] AS [EnvironmentVariable]
, fldr.name AS FolderName
, proj.name AS ProjectName
, COALESCE('Package: ' + pkg.name, 'Project') AS Scope
, objp.parameter_name COLLATE Latin1_General_CS_AS AS ParameterName
FROM SSISDB.catalog.object_parameters objp
INNER JOIN SSISDB.catalog.projects proj
ON objp.project_id = proj.project_id
INNER JOIN SSISDB.catalog.folders AS fldr
ON proj.folder_id = fldr.folder_id
LEFT JOIN SSISDB.catalog.packages pkg
ON objp.object_name = pkg.name
AND objp.project_id = pkg.project_id
-- Only search Projects/Packages that reference Environment variables
WHERE objp.value_type = 'R'
AND objp.referenced_variable_name LIKE '%SMTP%'
SELECT fldr.name AS FolderName
,objp.[referenced_variable_name] AS [EnvironmentVariable]
, proj.name AS ProjectName
, COALESCE('Package: ' + pkg.name, 'Project') AS Scope
, objp.parameter_name COLLATE Latin1_General_CS_AS AS ParameterName
,Objp.design_default_value
,Objp.referenced_variable_name
,(select top 1 Ev.value as VariableValue from SSISDB.[internal].[environment_variables] EV where ev.name=Objp.referenced_variable_name) as [value]
FROM SSISDB.catalog.folders AS fldr
INNER JOIN SSISDB.catalog.projects proj
ON proj.folder_id = fldr.folder_id
Left JOIN SSISDB.catalog.object_parameters objp
ON objp.project_id = proj.project_id
LEFT JOIN SSISDB.catalog.packages pkg
ON objp.object_name = pkg.name
AND objp.project_id = pkg.project_id
--WHERE proj.name like '%XXX%'
由于环境变量可以在项目或包级别使用,因此此查询将指示使用变量的所述级别并快速返回我想要的结果。希望这将在未来对其他人派上用场。
我已经修改了上面的答案查询以获取所有项目/包参数默认值和referenceVariable