SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to run scripts within an SSIS Package and how to execute an SSIS Package from a SQL script


How to run scripts within an SSIS Package and how to execute an SSIS Package from a SQL script

Author
Message
rons-605185
rons-605185
Right there with Babe
Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)

Group: General Forum Members
Points: 790 Visits: 162
New user to SSIS.

Used the Import/Export Wizard to create a SSIS package to extract data from Excel and import the data into an existing SQL table. Using the Flat File connection type. Some of the data has comma's in it and the import puts quotes around the strings with comma's in them. Need to remove the quotes in the SQL table so wrote the scripts below to do so and they work fine.

1) How do I include the replace/trim sql scripts in the SSIS package? In other words I want to have the SSIS package run the scripts to remove the quotes as part of the package process. Where and how is this done in SSIS?

2) Can a SSIS package be executed from within a SQL script? I would like to use a command button in my application that would run a SQL script or utility that would locate, call and execute the SSIS package. Can this be done and if so, how?

Thanks.


Quote Cleanup Scripts:


UPDATE dbo.IMP_tblImport
SET CompanyName = REPLACE(CompanyName,'"',' ')
WHERE CompanyName LIKE '%"%'

update dbo.IMP_tblImport
set companyname = (LTrim(Replace(CompanyName, ' ', ' ')))


UPDATE dbo.IMP_tblImport
SET Comments = REPLACE(Comments,'"',' ')
WHERE Comments LIKE '%"%'

update dbo.IMP_tblImport
set comments = (LTrim(Replace(Comments, ' ', ' ')))
RBarryYoung
RBarryYoung
SSC Guru
SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)

Group: General Forum Members
Points: 68134 Visits: 9519
1) Include a SQL Script Task in the control-flow, probably before your data-flow task runs.

2) Yes, but it is a Kludge and a potential security issue. SSIS, is not really meant for the development of end-user tools or functionality, it's really targeted at implementing operational features and background tasks.

However, if you feel the you must have this here are your options:

A) Have your client applications/SW run the SSIS package itself by using DTExec.exe at the command line. This is easily the most direct, least kludgey solution and it generally bypasses the security issues (because it just uses the Users or the Apps authorization, hopefully).

B) Write a stored procedure that uses sp_cmdshell to execute the package DTExec, at the command-line, from SQL Server. This works, but is obtuse (because you have to go out to DOS and then DTExec has to log back into SQL Server), and also could be a security problem.

C) Define a SQL Agent SSIS Job Step to run your package. This works, is probably secure, but is hard to implement (it's a PITA trying to run a Job from a session connection), and has reportability issues (as in, it runs asynchronously in another session, so your user will not know when its done or whether is was sucessful or not).

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
rons-605185
rons-605185
Right there with Babe
Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)Right there with Babe (790 reputation)

Group: General Forum Members
Points: 790 Visits: 162
Previous reply:

1) Include a SQL Script Task in the control-flow, probably before your data-flow task runs.

I know that there are 2 panes in BIDS that display the different flows but not sure how to access or edit them to place the script.
Can you give me details on how to do this? I am relatively new to SSIS.
RBarryYoung
RBarryYoung
SSC Guru
SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)

Group: General Forum Members
Points: 68134 Visits: 9519
Control-flow works like you probably think it does. You drop tasks on it and then, connect their arrows to control the order and conditions of execution.

Data-flow, is really the internal data routing of a Data
Transformation task. Once you have a Data Transformation task in your control flow, then you open it up to go to it's data-flow where you can drop components and then use the arrows to control how the data is piped from component to component. However, If you do not have one of those, then you don't have to worry about it (for this question, anyway).

----------

However, longer term, if you are planning to use SSIS, then you will need to learn all of this. It's a huge and complicated subject, and I strongly recommend that you look around for some books or articles to help you get started with it.

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search