SQL Server - parameter for data flow?
Asked By Tom Williams
17-Nov-09 11:22 AM
Typical disclaimer: I am pretty new at this SSIS stuff.
I need to transfer 35+ million rows from Oracle to SQL Server. At the
transfer rate I have seen so far, this will take about 29 hrs. Way too long.
I do not really need all 35 million rows right now. I'd like to transfer
rows based on a year value in the tables. Since there are 120+ tables, I'd
like to write select statements with a parameter for the year. Sounds
pretty basic to me, but I do not see how to read a variable into a select
statement in a data flow. Can this be done? Is there a better way?
Thanks
Tom
SQL Server
(1)
Oracle
(1)
CREATE TABLE
(1)
Database
(1)
LoadYear
(1)
Paramters
(1)
GETDATE
(1)
Year
(1)
Bob Barrows replied to Tom Williams
There are several ways, but they can be boiled down to two categories:
1. Dynamic SQL
2. mapping variables to parameters
If you choose dynamic sql, then my preference is to create a variable
based on an expression. Then set the source property in your data flow
task to the variable.
http://sqlblog.com/blogs/andy_leonard/archive/2009/01/31/ssis-expression-language-and-variables.aspx
If you choose parameters, then my preference is to use an ADO.Net
connection manager so I can use named paramters rather than indexed
parameter markers. You should be able to find an example for this in SQL
BOL with minimal effort.
As to getting the parameter value into your package, you can use a
Package Configuration. Todd has a good blog about this:
http://toddchitt.wordpress.com/2008/06/27/ssis_config
--
HTH,
Bob Barrows
Todd C replied to Bob Barrows

Actually, I would not use my Config database for this. I reserve that
primarily for Connection Strings and other values that change when migrating
a package from DEV to TEST to PROD (though it would certainly work).
I would set up a 'control' table;
CREATE TABLE dbo.YearList (
LoadYear INT,
LastLoaded DateTime )
Populate it with all the years you want loaded, leaving the DateTime field
as NULL.
Then first Task on your Control Flow, have an Execut SQL Task with:
SELECT MIN(LoadYear)
FROM dbo.YearList
WHERE LastLoadeded IS NULL
That should return a single INT value, which you would put into a Package
Variable using the Result Set. Now use that Package Variable as a parameter
when you do all your SELECT statements against the Oracle Db.
Lastly, you need to update the control table to tell it that the particular
year was loaded. Do this with another Execute SQL task:
UPDATE dbo.YearList SET LastUpdated = GETDATE() WHERE LoadYear = ?
and map the Package Variable to the parameter.
Now you have a package that you can run once a night and it will always get
a different year each time, without you needing to do any manual table
manipulation.
HTH. Good luck.
=====
Todd C
Bob Barrows replied to Todd C
So would I. Actually, I got the idea for doing so from reading your
blog, so i guess I was hoping the OP would make a similar leap rather
than spelling it out for him :-)
... ok, I got lazy!
--
HTH,
Bob Barrows
Security at Row Level Within SQL Server SQL Server Oracle has a feature called "Virtual Private Databases" (VPD), that enables you to configure permissions at row level. Is there an equivalent feature in SQL Server?" SQL Server Security Discussions SQL Server (1) Oracle (1) Databases (1) Russel (1) Wang (1) Publicsector
SQL Server vs PostGress , DB2 and Oracle SQL Server We are looking @ changing our Oracle DB with either SQL Server 2008 R2, PostGress or DB2. Does SQL SErver 2008 R2 support Pl / SQL? SQL Server
Is there sth like Direct-Path-Loads in SQL-Server SQL Server I am familiar with direct-path-loads and SQL*Loader on Oracle. Does anyone know if sth like this is available on SQL-Server? SQL Server Discussions SQL Server (1) Oracle (1) Hi Franz Tibor replied to this in
Replication from Access to SQL Server SQL Server Is it possible to replicate data from Access (2000 or 2003) to SQL Server (2000 or 2005)? SQL Server Replication Discussions SQL Server (1) Microsoft Access (1) Oracle (1) SQL Server 2000 can function
replication sql 2000 - -> sql 2005 SQL Server , sql, 2005" / > Is it possible to replicate a db from sql server 2000 to sql server 2005? When I set the publications, I look this "select all of the types