Is it possible to redirect the Exceptions occurred to another table/log, in Script Task ? If so, How is it to be done ?
You can do anything in a script task that you can do in vb.net or C#. But if you are doing so much in a script task, why do you need to use SSIS. SSIS handles most things like exception logging, error handling, etc fairly well. You should use SSIS for what it does and only sparingly go to a script task when you are trying to do something specific that SSIS does not handle well. To have an SSIS package that simply has a Script Task in it that handles everything, would be like having a vb.net program that calls a C# dll for all of the work. If you wrote everything in C# why would you need the vb.net wrapper?
Related
If I create an SSIS package in SSDT that has an error of some sort, save the package, then close and reopen it, it will do validation upon opening the project and alert me of any errors. However, this is the only way I have found to find if I have any errors. If I simply click Build, it will do so without any errors, so this is not the same process as the initial validation. Do I really have to close out of the package and reopen in SSDT to get this functionality? The only other way I have seen is actually during runtime after executing the package. I'm looking for a way before execution.
Task Validations occurs when you open the package if you are working online. This is useful because it finds errors in a package, in most cases with its connections.
If a package contains many connections(SQL or file or others), and every time you open the package, one has to wait several minutes for the validation to complete. If one wants to skip this, change the SSIS to work offline(SSIS->Work offline). This has no affect running the SSIS package as SQL Server Job.
Otherwise, this validation is ALWAYS done automatically before the package executes. If the tasks have validation errors, the execution fails.
The only way I know to explicitly validate the SSIS package is from SSMS Integration Services Catalog. Here you can go to a particular SSIS package and right click on the package you need to validate. Of course, the package needs to be deployed for this.
I am new to SSIS. My problem is , I have to do a databse query. Then, I have to do a web service call passing in the result that I got from the db query, to the web service .
Either I can use sql task first for db query and web service task next for web service call. Another way is to do do entire thing in the c# code and put that in script task.
I can use enterprise library for doing db query through the C# code and then call the web service.
What is the better approach to do it ?Which one gives better performance?
Both approaches can work. Both will likely result in approximately the same performance - usually the query execution on SQL Server is the slowest part, and it does not matter how you invoke it.
But if you do everything in C# code and put it in script task - what is the benefit of SSIS? You can as well do everything in C# and put it in standalone console app.
Usually one uses SSIS to avoid writing code, and use declarative program definition - which is more maintainable, easier for others to understand and support, etc. Someone who opens a package and sees SQL task and Web Service task will be able to understand and tweak what's going on without opening Script Task and examining the code. It also requires less developer expertise to maintain such package.
Script Task is then only used when something can't be done directly by existing SSIS task or transform. If I saw a package with all the code in a Script Task - I would ask why the person used SSIS at all? Doing it with standalone console app would be simpler, more reliable (than the same code inside Script Task), avoid unnecessary dependency, etc.
Short: if you DO use SSIS - avoid Script Task when possible.
In VB pseudocode, I'm trying to accomplish the following using SSIS (either 2008 or 2005)
If FileHasAlreadyBeenDownloaded = False Then
DownloadTheFileFromFTP
End If
ImportTheDownloadedFile
To do this in SSIS I have a script task to check for the file, and if it exists it transfers directly to the DataFlow Task using conditional expressions. If the file doesn't exist, it transfers to the FTP Task, and the FTP Task transfers to the DataFlow Task.
It seems, though, that I can't have two tasks lead into one common shared task, because no matter which path the code takes it won't execute the DataFlow Task. If I make a copy of the DataFlow task and have each path go to its own Task, then all works perfectly.
Is this a documented thing with SSMS that I just haven't found? I looked through 31 pages of questions on SSMS before posting, so hopefully this isn't a stupid question.
I also tried using Expressions on the FTP task to set "Disabled=#FileAlreadyDownloaded=True" but that works only in SSMS 2008 and didn't seem to work in SSMS 2005.
Thanks so much for any pointers on this!
It might be worth trying putting the script task and the FTP task inside a container task, and link the the container to the data flow task on success.
I'm trying to programmatically add an Execute SQL task from within a script task of my SSIS package. I know that the Microsoft.SqlServer.Dts.Runtime.Package class has an Executables collection which I can add my new task to but how to I get a reference to the package Im inside of?
It is not possible, SSIS does not support self-modifying packages.
To prevent any attempts of doing what you are trying to do, the task code does not have access to the package API, so you can't obtain reference to Package object from a task. But even if you find a way to curcumvent this - the results are not predictable, as package is not allowed to modify itself at runtime.
If you could describe what you really want to achieve (rather than asking for particular way to do it) - someone might find a way to do it. Maybe you can use child package - it is OK to modify child package before its execution, or maybe it is enough to just change some variables that are used by Execute SQL task later in this package?
As Michael says above, it's not possible to do what you are asking. However, you may be able to find a solution by setting variables at runtime, or by enabling or disabling certain packages at runtime using dtexec. For example:
dtexec /f e:\ssis\master.dtsx /set \Package\YourPackageName.Disable;True
For my requirement I need to write Script task from One SSIS package to another. As my server is 64bit machine, when I execute the overriden SSIS package, it throws the error "Binary Script not found". Hence I need to compile the script programmatically in the Parent SSIS package and put the binary code into the another one. I dont know how to compile the Script programmatically.
Let me know how to do that
I don't think you can do this with SSIS. If there's a way to accomplish this using a Parent Package / Child Package architecture, I'm unaware of it.
You can get more flexibility creating packages dynamically in .Net. Although I haven't tried to dynamically compile script task code.
I'm curious: Why not copy the code out of the parent package and paste it into a child package?
:{> Andy
So you need to somehow programatically execute a (Debug>Build). This typically gets around the problem of binary not being found, when you do it manually in VS. Doesn't strike me as possible at runtime though.