用于为SSIS项目创建SSISDB的SQL脚本

问题描述:

我在想,如果我们可以在SQL Management Studio中通过T-SQL脚本创建SSIS SSISDB而不是手动创建SSISDB?用于为SSIS项目创建SSISDB的SQL脚本

感谢

+1

你是什么意思的SSISDB和你有什么尝试。 –

+2

SSISDB目录是存储SSIS包,参数,项目,权限等的数据库。基本上,它是管理SSIS项目的中心位置。它是在SQL Server Management Studio中创建的。我知道如何手动创建(通过右键单击SQL Management Studio中的Integration Services目录),但想要使用T-SQL脚本的方式,以便我可以在test/uat/preprod环境中自动创建此数据库,而无需执行此操作手动在每个不同的环境中。 – SHB

不要认为它可以从T-SQL来完成,但基于this MSDN page,你可以通过PowerShell的编程方式做到这一点:

# Load the IntegrationServices Assembly 
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") 

# Store the IntegrationServices Assembly namespace to avoid typing it every time 
$ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices" 

Write-Host "Connecting to server ..." 

# Create a connection to the server 
$sqlConnectionString = "Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;" 
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString 

# Create the Integration Services object 
$integrationServices = New-Object $ISNamespace".IntegrationServices" $sqlConnection 

# Provision a new SSIS Catalog 
$catalog = New-Object $ISNamespace".Catalog" ($integrationServices, "SSISDB", "[email protected]") 
$catalog.Create() 

你要改变的行其中定义$ sqlConnectionString以匹配您的目标环境,并将倒数第二行的[email protected]替换为您自己的密码。

+0

感谢3N1GM4。是的,我认为Powershell是以编程方式创建SSISDB目录最合适的方式。 – SHB

+0

没问题,很高兴这很有帮助。感谢您接受我的回答。 – 3N1GM4