2016-11-14 31 views
0

我在想,如果我們可以在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

回答

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", "[email protected]") 
$catalog.Create() 

你要改變的行其中定義$ sqlConnectionString以匹配您的目標環境,並將倒數第二行的[email protected]替換爲您自己的密碼。

+0

感謝3N1GM4。是的,我認爲Powershell是以編程方式創建SSISDB目錄最合適的方式。 – SHB

+0

沒問題,很高興這很有幫助。感謝您接受我的回答。 – 3N1GM4