Hello All,
Can you please let me know Is there any way to restore multiple SSIS Packages into SQL Server 2008. In otherwords, we have multiple SSIS packages as storage files (.dtsx) and we want to restore them all in SQL Server MSDB in one shot.
We have already achieved this for SQL Server 2000 DTS Packages using the below code. Can you please let me know Is there any similar kind of way to achieve the same for SSIS Packages.
Step 1:
List all the DTS Packages that need to restored in text file "Dislist.txt" in a file path (C:\TEMP).
Place all the DTS Packages in C:\TEMP
Step 2
Create C:\TEMP\RestoreDTS.vbs. Copy and paste the code below into RestoreDTS.vbs and save the file.
SQlServer=WScript.Arguments(0)
Filename=WScript.Arguments(1)
const TrustedConnection = 256
dim version1
Set oPackage1 = CreateObject("DTS.Package2")
oPackage1.LoadFromStorageFile Filename,"","","",""
oPackage1.SaveToSQLServer SQlServer, , , TrustedConnection
Set oPackage1 = Nothing
Step 3
Create C:\TEMP\Restore.bat. Copy and paste the code below into the file and save it.
REM Objective: Load DTS package and save it to SQL Server
REM Type: Batch File to get all DTS package name
REM Parameters
REM %1 = SQl Server box name (The SQL Server instance name where the DTS packages need to be restored)
REM %2 = directory name
@Echo on
REM Export DIR listing to C:\TEMP\Dirlist.txt
cd %2
Echo "Load Started"
Date/t
time/t
dir %2 /b > C:\TEMP\Dirlist.txt
REM Restore all the DTS package listed in C:\TEMP\Dirlist.txt
for /f "tokens=1" %%i in (%2\Dirlist.txt) do Cscript /nologo RestoreDTS.vbs %1 %2%%i
REM echo %2%%i
Echo "Load Completed"
Date/t
time/t
Step 4:
Execute the below query in SQL Query Analyzer to restore all the packages to SQL Server.
SET @query = 'C:\TEMP\Restore.bat ' + @@servername +' C:\TEMP\DTS C:\TEMP\RestoreDTS.log'
USE MASTER
GO
-- Save DTS Packges to Database
EXEC master..xp_cmdshell @query