I am using SQL Server 2005. I have a few SSIS packages located here: C:\SSIS
This code below is used to execute all the packages but I still need to place each package name in a table called Packages.
Can I execute all the packages without having to save the package name? I just want to supply the path of where they all are sitting and want SQL to do the rest.
DECLARE @package_name varchar(200)
Declare @PackageCount int
Declare @X int
Set @X = 1
Set @PackageCount = (Select COUNT(*) from Packages)
set @FilePath = 'C:\SSIS'
While (@X <= @PackageCount)
Begin
With PackageList as
(
Select PackageName, Row_Number() Over(Order by PackageName) as Rownum
From Packages
)
SELECT @package_name = PackageName
FROM PackageList
Where Rownum = @X
select @cmd = 'DTExec /F "' + @FilePath + @Package_name + '"'
print @cmd
Set @X = @X + 1
exec master..xp_cmdshell @cmd
End