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

时间:2016-11-14 16:39:32

标签: sql-server tsql ssis ssms

我想知道我们是否可以通过T-SQL脚本在SQL Management Studio中为SSIS创建SSISDB而不是手动创建它?

由于

1 个答案:

答案 0 :(得分:1)

不要认为可以从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", "P@assword1")  
$catalog.Create()

您需要更改定义$ sqlConnectionString的行以匹配您的目标环境,并将倒数第二行的P@ssword1替换为您自己的密码。