I am using SQL Server 2012
and I need to create an SSIS
package that will run a list of T-SQL
queries from a specific folder.
My list of T-SQL
queries have been named starting with '01 (name of query).sql' and the folder contains a list of 25 queries. I need the task to run these queries
starting with query '01...' to '25...'
Can this be created in an SSIS
package? If yes, which task should I use?
Update 1
I tried the first method suggested by @Hadi and the script task throws the following exception
Error: Exception has been thrown by the target of an invocation
screenshot of my task in SSDT
Script Task VB code
<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Public Sub Main()
Using sr As New IO.StreamReader(Dts.Variables("strFilename").Value.ToString)
Dts.Variables("strQuery").Value = sr.ReadToEnd()
sr.Close()
End Using
Dts.TaskResult = ScriptResults.Success
End Sub
End Class
Variables