SSIS - Script Debugging
From SQLServerPedia
|
See Also: Main_Page - Code Management - Loaders - Integration Services (SSIS) To facilitate SSIS script development, Visual Studio for Applications supports extensive debugging capabilities. You can right click on the line of code in your script and choose Breakpoint -> Insert Breakpoint. Alternatively you can simply click in the grey area on the left of the script to add a breakpoint to your code. Once you add a breakpoint, the entire line of code turns red. Once you exit Visual Studio for Applications, you'll notice that the script task will also have a red button indicating that it contains a breakpoint. You can choose Debug -> Start Debugging within BIDS to invoke the execution of the script task. The task will stop at the first breakpoint. Note the locals' window on the bottom. You can activate or hide this window by choosing Debug -> Windows -> Locals. This window shows you the variables available within your script: "Me" variable refers to the script task itself, dbCount is the local variable we declared to store the count of Analysis Services databases. MyServer variable references the connection to the local Analysis Services server and exposes numerous properties. If you choose Debug -> Step Into within Visual Studio for Applications, the script will execute one line at a time. For example, the line that is highlighted on the above screenshot will establish a connection to an instance of Analysis Services. At this point the "connected" property of myServer variable will become "true". Once you execute the next line the value of the dbCount variable will become 5, because the local instance has 5 Analysis Services databases. You can examine the values of your variables in the locals' window or by placing the cursor over the variable name within the script. Another very useful debugging option is available directly from the control flow. If you right click on the script task and choose Edit Breakpoints you will see another window where you can define not only the conditions under which the execution of the script will stop, but also how many times the condition must be met before execution will halt. For example, OnWarning event will allow you to examine the values of your variables and other objects if the code raises a warning. You might not want to stop the execution for every warning, but if you see too many warnings then you might wish to halt execution to see what might be the root cause of this condition. If you click on Hit Count Type column next to the selected breakpoints you can change the value of "Always" to "Hit count equals", "Hit count multiple" or "Hit count greater than or equal to". Next, you can define the target number of hits by changing the value of "Hit Count" column. Note also that Set Breakpoints' window found the existing breakpoint on line 18 of ScriptMain method. We might only wish to examine the state of execution if this line is called repeatedly, perhaps within the loop. You can customize the behavior of the breakpoint from this window. You can subsequently review all active breakpoints by choosing Debug -> Windows -> Breakpoints within Visual Studio for Applications' environment. |