Showing posts with label flat. Show all posts
Showing posts with label flat. Show all posts

Monday, March 19, 2012

Changing SQL Server Agent settings on the fly?

Hello all,

I have created a simple package that imports data from a flat file into a database. To run the package I'm using a SQL Server Agent Job. The location of the file is stored as a connection string in the Connection Managers tab in the SQL Server Agent Job.

Is there a way to change this connection string programmatically? If not programmatically, is there a way to change this setting right before I execute the package. I want to change the location of this file based on user input. Also, I'm executing the package using the sp_start_job stored procedure to run the job.

Thanks in advance for any advice!

-Dwayne

You could just create the entire job on the fly, they can be scripted in T-SQL.

If you want to keep the job, then you could use sp_update_jobstep to update the step command. Now I have not looked at the command for the SSIS subsystem, but I'd recommend use the CmdExec subsystem and calling DTEXEC myself, the logging is much better. Even MS recommend that approach in one of their KB's now. BTW could read it here first, illustrates why - http://wiki.sqlis.com/default.aspx/SQLISWiki/ScheduledPackages.html

Finally leave the job alone, and store the value in a table. You could manually use the Exec SQL Task to query the value, or perhaps better still use a SQL server based configuration. Have a look in Books Online about configurations, they are very useful, and I suggest you use them anyway to help manage connection details.

Thursday, February 16, 2012

Changing flat file connection file name property

Hi,

I have a task to traverse a folder of CSV files of same format and then populate into one sql server table.

Is there a way where I can change the source CSV file name runtime using FOR EACH loop container for flat file connection manager ?

any help would be much appriciated.

Thanks,

Furrukh Baig

Yes. By using package expressions. There is an example in the SSIS tutorials that I think does exactly what you want to do assuming all files are in the same directory.|||Thanks mate... you are star ...|||

I'm also trying to do the same thing, except that each folder has a number of different csv files. Would appreciate if someone could give me a link of the sample (as mentioned in the previous post) and whether it's better to have different flat file source for each type of csv file format or should I just use 1 flat file source.

I've tried using 1 flat file source but the number of columns are different for each files and the number of columns in the flat file source isn't dynamic (I've to prespecify it first).

|||I'm assuming you're talking about the foreach loop container in the tutorial (ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.SQLSVR.v9.en/sqltut9/html/88a973cc-0f23-4ecf-adb6-5b06279c2df6.htm) Can you use a similar concept to loop thru xml files? I have an xml source, 2 sorts and a merge-join. Whenever I change the input file, I need to open my sorts and click ok. How will that work if I need to iterate thru a directory of files?

Changing flat file connection file name property

Hi,

I have a task to traverse a folder of CSV files of same format and then populate into one sql server table.

Is there a way where I can change the source CSV file name runtime using FOR EACH loop container for flat file connection manager ?

any help would be much appriciated.

Thanks,

Furrukh Baig

Yes. By using package expressions. There is an example in the SSIS tutorials that I think does exactly what you want to do assuming all files are in the same directory.|||Thanks mate... you are star ...|||

I'm also trying to do the same thing, except that each folder has a number of different csv files. Would appreciate if someone could give me a link of the sample (as mentioned in the previous post) and whether it's better to have different flat file source for each type of csv file format or should I just use 1 flat file source.

I've tried using 1 flat file source but the number of columns are different for each files and the number of columns in the flat file source isn't dynamic (I've to prespecify it first).

|||I'm assuming you're talking about the foreach loop container in the tutorial (ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.SQLSVR.v9.en/sqltut9/html/88a973cc-0f23-4ecf-adb6-5b06279c2df6.htm) Can you use a similar concept to loop thru xml files? I have an xml source, 2 sorts and a merge-join. Whenever I change the input file, I need to open my sorts and click ok. How will that work if I need to iterate thru a directory of files?