Empty Text File in SSIS Package - sql-server-2008

In my Project, I want to create one empty text file when the package triggered.

I'd probably just use a one-line Script task.
System.IO.File.Create(#"C:\OneEmptyTextFile.txt");
On your Control Flow, drag a Task of type Script Task from your SSIS Tool Box
Double click on the new Script Task
In the Script Task Editor, click Edit Script...
In the public void Main() section, where it states // TODO: Add your code here replace that line with the above code. If you are using SSIS 2005 or if you have chosen to use VB.NET in 2008/2012, please remove the trailing semicolon.
Click the X button in the upper right corner of the Integration Services Script Task window
Back in the Script Task Editor, click OK.
Now whenever that Task runs, it will use the static Create method of the File object to create a file in the requested location.

It might be good idea to dispose of the FileStream object after using the File.Create method to avoid locking issues.
Read more here System.IO.File.Create locking a file

Related

Octave GUI: right-click and edit function in a script file

In the Editor window of Octave GUI, if I right click on a function (say, f1) in an expression where it is called, and "Edit f1", function file f1.m opens.
But if my function (now plot_color_marker_ranges) is defined in a script file instead of a function file, when I right-click in an expression where it is called (1) and "Edit" (2) I get the following message
(1)
(2)
Can I get hyperlinking and navigation when a function is defined in a script file instead of a function file?
Steps to reproduce
Create script file myscript.m containing a function f1.
This script file has as its first command 1;.
Create script file mymain.m, and add an expression that calls f1.
Add also source('myscript.m') above the first call to f1.
This script is in the same directory as myscript.m.
At this point, both files were saved on disk.
Run mymain.m from the Editor window of Octave GUI to make sure f1 is correctly used from mymain.
Navigate in the Editor window of Octave GUI to the expression that uses f1.
Right click on any part of the text "f1".
Click on "Edit f1".
EDIT:
Notes:
This helps a lot with editing and debugging.
As of now, whenever I need to debug I set an M-file for the functions. Then I may transfer the function to a script file.
Using Octave 5.1.0 configured for mingw32 under Win 10.

Invoking series of commands in a new tab in cmder

TLDR:
I want to use something like -new_console:t:tabname to open a new named tab in cmder and then transfer focus/control to that tab so that the rest of the commands I'm sending from a Python script run in that console instead. Or, I want to rename a cmder tab from a script running in the console.
DETAILS:
I often have to execute a series of commands in cmder in order to test the latest code from our continuous integration environment. Because there are several applications I often have to have running at a time, it would be helpful for me to have the cmder tabs named according to which application they are running.
The only way I've found to set a tab name from within cmder (apart from manually with mouse clicks) is to do so with the -new_console:t:tab_name command. But that only runs the next command in the newly opened tab, and not all the things that come after it.
I kick off all my commands with a Python script that accepts parameters to let me control which application opens and how things behave. I'd like to do something like this:
os.system('pwd "-new-console:t:' + args.app + '"')
so that a new tab opens with the name of the app I'm about to invoke in it, starting with an indication of the present working directory. But then I'd like all the commands that follow from the Python script to be run in this new tab instead of in the tab used to kick off the Python script. This includes printing some flowerboxed comments, but also invoking a local application server that will continue running.
Is there any way to, as you create a new (named) tab in cmder, transfer focus to that tab so that all future commands run in that tab instead of the initiating tab? Alternately, is there any way from within a cmder console to rename the cmder tab it's running in? That would be just as good.
Thanks!
Thanks for looking, but I found the answer.
In the bottom right corner is a hamburger stack. Click on that and select Settings. In General --> Tab bar, change the Console setting from the default %n to %s. Then the "title" command will change the tab name.

SSIS Execute Package task notification if path does not exist

I have created a master control package that calls several packages using the execute package task control. I have set all the package file locations to use a sql config table which contains the file location and then used an expression to include the package name. Everything works as expected however I want to include some handlers to notify me if the package location does not exist (just in case somebody changes the path in the config table). To test I set an incorrect file name in one of the expressions which turned the execute package task control red as expected however I can't figure out how to add the notification task. I have tried all the error handler events assocaited with it but no joy plus I added a mail task to the task in question for failure and this did not execute!
Any advice greatly appreciated.
Thanks.
That's why you have OnError event handler, just configure it properly. Are you sure, you're checking Event Handlers for the package and not for one of the blocks inside?
There's a plenty of system variables with OnError scope. Check grey x in Variable window to see them. You might want to use:
- ErrorDescription
- ErrorCode
- SourceName
but choose them according to the report format.
Now in event handler create a script which will put a message into a new variable, and finally send it with send mail task.

Where can I find the PreExecute method in SSIS script component?

I am trying to call a Net.TCP WCF service within my SSIS package. I have set up the script component, changed the .NET Framework to 3.5 in the Service Reference. I am creating the sample package based on the example provided in the below link.
How to Configure an SSIS Package to Access a Web Service using WCF
The link states to override the PreExecute method but I am unable to find the method within the script component in SQL 2008 R2.
The script component in my package begins with the following code:
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
However, the example written in the above-mentioned article has the below code:
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
I've tried just copying the code across then to fix the relevant references but no where does it contain a reference for UserComponent.
Could someone point out what am I doing wrong here?
Cause of the issue:
You are using the Script Task available on the Control Flow tab instead of the Script Component transformation available within Data Flow Task.
SSIS 2008 R2 package illustrating the differences:
Create an SSIS package in Business Intelligence Development Studio (BIDS) 2008 R2 and name it as SO_10121670.dtsx.
BIDS will be default display the Control Flow Tab. From the toolbox, drag and drop Script Task and Data Flow Task as shown below.
Double-click Script Task to view the Script Task Editor. On the Script Task Editor, click Script page and then click Edit Script...
Integration Services Script Task code editor will open. You will notice that the class ScriptMain inherits from Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
The example it the MSDN article does not use this Script Task.
On the Control Flow tab, double-click Data Flow Task to switch to the Data Flow tab. Drag and drop a Script Component from the Data Flow Transformations section on the Toolbox.
When you drag and drop a Script Component, the Select Script Component Type dialog will appear. You have to choose the appropriate one that suits your requirements. This sample sets the type to Source so we can view the script editor. Click OK.
Double-click the Script Component to view the Script Transformation Editor. On the Script Transformation Editor, click Script page and then click Edit Script...
Integration Services Script Component code editor will open. You will notice that the class ScriptMain inherits from UserComponent. This is the component that you need to use to practice the WCF sample code in the MSDN blog article.
You can see the PreExecute method inside the Script Component code that you have been looking for.

How do I automate a saved import in a macro in Access 2007?

I have created a macro to run a saved import (a file imported from Excel into Access 2007). When I run the macro, the saved import runs and the following happens:
A "Manage Data Tasks" window pops up.
I have to choose from the following options: Run, Create Outlook Task..., Delete, and Close.
If I select Run, the next pop-up asks, "Overwrite existing table or query?"
I have to choose: Yes or No.
Another window pops up and says, "All objects were imported successfully."
I have to click the OK button.
I have to click the Close button on the "Manage Data Tasks" Window.
Is there any way that I can automate all these button clicks if they are always going to be the same? (The bold faced buttons are the ones that I'll always be clicking.)
If you use the DoCmd.RunSavedImportExport Method you won't have to interact with the Manage Data Tasks dialog at all.
DoCmd.RunSavedImportExport "YourSavedImportName"
You will however have to deal with the possible errors that get raised. For example if your source file is unavailable you will get an error like
Run-time error '3011':
The Microsoft Office Access database engine could not find the object
'Sheet1'. Make sure the object exists and the you spell its name and
the path correctly.
This may be too simple, but can you use the Setwarnings:off command in your macro before you import.
Now I would like to see the macro to automate the import