Back to Browse

Regular Expressions: Let's fix scripted SSIS environment variables

182 views
Jul 29, 2022
25:27

Regular Expressions save the day, yet AGAIN. When you script SSIS environment variables it gives you all the stored procedure calls you need, but all the values are hardcoded in each line. This isn't as usable as I'd like, so here I show you how to use RegEx to reformat the code produced by SSMS so it's more readable, and easier to extend. Each parameter will go from this: EXEC [SSISDB].[catalog].[set_object_parameter_value] @object_type=20, @parameter_name=N'Date_Month', @object_name=N'MonthlyMarketing', @folder_name=N'MarketingReport', @project_name=N'MonthlyMarketing', @value_type=R, @parameter_value=N'Date_Month' To this: ------------------------------------------------------------------------------ ------------------------BEGIN 'Date_Month'--------------------------------------- ------------------------------------------------------------------------------ SET @object_type = 20; SET @parameter_name = 'Date_Month'; SET @object_name = 'MonthlyMarketing'; SET @folder_name = 'MarketingReport'; SET @project_name = 'MonthlyMarketing'; SET @value_type = R; SET @parameter_value = 'Date_Month'; EXEC [SSISDB].[catalog].[set_object_parameter_value] @object_type = @object_type, @parameter_name = @parameter_name, @object_name = @object_name, @folder_name = @folder_name, @project_name = @project_name, @value_type = @value_type, @parameter_value = @parameter_value; ------------------------------------------------------------------------------ ------------------------END 'Date_Month'--------------------------------------- ------------------------------------------------------------------------------

Download

1 formats

Video Formats

360pmp437.5 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Regular Expressions: Let's fix scripted SSIS environment variables | NatokHD