In SSIS how can I check if the package or task is being run within BIDS by using the play button or right-clicking and choosing Execute Task? - ssis

This is not the same as debug mode. I want to display a warning if the developer is actually in BIDS and not display the warning if the package is being run from a scheduled job.

You could use a script task that opens a MsgBox. The MsgBox would only open when the task is running in BIDS, if I am not mistaken.

I'm afraid what you are trying to achieve is not possible. BIDS uses the same runtime as your SSIS agent.
You could, however, set an environment variable in your package and remove it during deployment. All of this is hacky and defeats the purpose though.
There really should be no custom logic when running a package locally versus being deployed (other than configurations that might affect the execution graph).
If you are trying to prevent user-error it would be best to educate your peers and/or restrict access.

I have found but not checked that there is a system variable "System::InteractiveMode" that may be used for this. Something to check.

According to Microsoft's documentation on System Variables the InteractiveMode variable should be able to fulfil your need to determine if the package is running from BIDS or from a SQL Job.
InteractiveMode (Boolean)
Indicates whether the package is run in
interactive mode. If a package is running in SSIS Designer, this
property is set to True. If a package is running using the DTExec
command prompt utility, the property is set to False.
I created a Script task at the beginning of my Flow (in the control flow tab) with a precedence constraint on the following task. I defined System::InteractiveMode in the ReadOnlyVariables field and used the code below to display the question and process the answer.
public void Main()
{
if ((bool)Dts.Variables["InteractiveMode"].Value)
{
DialogResult button = MessageBox.Show("Are you sure you want to run the package?", "Validate", MessageBoxButtons.YesNo);
if (button == DialogResult.No)
{
Dts.TaskResult = (int)ScriptResults.Failure;
return;
}
}
Dts.TaskResult = (int)ScriptResults.Success;
}
It doesn't stop the execution like the stop button in BIDS but prevents the execution of the rest of the package. I tried to use the RunningPackage.Stop() method but in order to get the list of RunningPackages it requires to be running from SQL Server Integration Service.
I tested it from BIDS and from SQL Server integration service and it worked as expected.

Related

SSIS ForceExecutionResult not working

I have a package, inside which contains a script task, due to probably C# library issues in some of the servers, this task may success in some machines but fail in others (reporting Cannot load script for execution).
I want to force the task to be success by setting the ForceExecutionResult = Success option for this task. However when running, I found this doesn't work, the task still fails in the old-fashioned way.
I don't want to modify the MaxErrorCount for package because I want to reveal errors from other components, in the meanwhile, even this script task fails during validation, I want the package report success, is there any way to make the solution?
To let your package continue execution, you can set the DelayValidation property to True on the Script Task (so the package will begin executing), then on the Precedence Constraint that follows this Script Task, set it to continue on completion, instead of success.

In SSIS Break points cannot be set to

In SSIS online test, I got this question.
Breakpoints cannot be set to:
1. Task,
2. container,
3. package,
4. script task.
Help, please.
To score the point, select "4. Script Task" but as others have stated, that really is a poor question.
Before I begin my explanation, please note the difference between a "Script Task" and "Script Component." The Script Task is used on the Control Flow. The Script Component is used inside a Dataflow. The Script Component was not able to be debugged using breakpoints in SSIS 2008. This changed with SSIS 2012.
However, the question mentions Script Task. To my knowledge, Script Tasks have ALWAYS been able to hit breakpoints. We just need to take some steps to enable it.
Set the SSIS Project's "Run64BitRuntime" propery's value from its default True to False.
Edit your Script Task with "Edit Script" and save it again. This will help your script task code to be compiled as 32bit.
Once both your project and script task are compiled and executing in 32-bit mode, the breakpoints will be hit. See here for more information.

MS Access Compile and Run

I am new to MS Access. I am building a simple project and I already have created the tables, forms and queries. My question is, how would I compile and run my program ? Is there "F5-like" to run my project on MS Access ? Or how am I going to do this? Thank you.
In other Microsoft environments, F5 is the shortcut key for "Start Debugging", or "Run", or words to that effect. When the application starts it performs a default action:
Windows forms-based applications will display the startup form
Windows console applications will start running at static void Main()
ASP.NET applications will display the default page (Default.aspx).
Unfortunately, while the VBA development environment does have an F5 shortcut key to run code (and it can be very handy during development), it doesn't mean the same thing as it does in the other environments listed above.
To "run your project" in Access you need to manually perform whatever action you have specified as the default action when the database is opened. That is normally one of two things:
If you have created a Macro named AutoExec then Access will run that, or
If you have specified a startup form (see screenshot below) then Access will open it.
So, to launch your Access project simply open the startup Form or run the AutoExec Macro. (Or, you could always just close the database and re-open it, and let Access perform the default action for you.)
make sure you have ODBC access support to run your program

SSIS 2008 User Variable in Expression for Execute Process Task

I have an SSIS 2008 package.
I have 3 user variables in the package. One is for an the environment, one is for the path for an executable, and the other is part of a message for an email.
I have a Script Task that sets the variable for the path (strAppPath) based on the environment variable.
strAppPath is used in an expression for the Executable property of an Execute Process Task. The job fails stating that the executable path for the Execute Process Task is not set.
I'm assuming that it is checking this path before the Script Task sets the variable.
Is there a way to work around this?
Right click on your Execute Process Task and select Properties. In the properties window, you will have a DelayValidation option that is currently set to False Flip that to True.
What is happening is that when the package starts, it goes through a validation phase to ensure everything is kosher before it begins (no need to start processing if something is broken). In your case, that full validation is not desired as the Execute Process Task won't be valid until right before it's time to run. The validation will occur, just that it is delayed until it is time for the task to begin. Make sense?

SSIS package script logging

I am new to SSIS packages and I am trying to get logging to work from within a custom script. We have it logging the native messages from the package already but I want to add my own custom log messages to it. I see on the Microsoft.SqlServer.Dts.Pipeline.ScriptComponent class there is a Log method but I am unsure what to use for the dataCode and dataBytes arguments so I used 0 and an empty array but this did not log anything.
So how do I get the logging to work from within my script?
Are there any configurations that I need to know about to enable it?
Thanks
Note: I am working with SqlServer 2008 SP2 (not R2)
You need to make sure that the task is enabled for logging. Select SSIS > Logging... from the BIDS menu. Select your data flow task. On the Providers and Logs tab, ensure that a log provider is selected. Select the Details tab and Check the ScriptComponentLogEntry event. Note that this event is not inherited from the Package settings; so you have to select the data flow task. Now your logging should be captured.
You may also be interested in the ComponentMetaData.FireInformation method to log an information event. Here's more information on FireInformation and related methods. You may find these easier to configure, since the associated events (OnInformation for FireInformation) are inherited from the package settings. In other words, if you set logging for the OnInformation event at the package level, all tasks will log the OnInformation event.