?
SolvedPrivate

SSIS Data Load

Posted on 2013-05-17
3
Medium Priority
?
34 Views
Last Modified: 2016-02-10
Hi Experts,

I have attached a query below. It is returning the results I want perfectly. Now I will have to load the results starting from '2009-01-01 00:00:00.000'  until '2013-05-16 00:00:00.000'. I will have to load the daily records stating from '2009-01-01 00:00:00.000' period into my table i.e

 where
rec_create_date between convert(varchar,'2009-1-01 00:00:00.000',102)
and convert(varchar,'2009-01-02 00:00:00.000',102)

and again
where
rec_create_date between convert(varchar,'2009-1-02 00:00:00.000',102)
and convert(varchar,'2009-01-03 00:00:00.000',102)

so on and so forth. These records are coming from Prod into my Rep Server. It is very tough to change the date everytime I run the package on the where condition. Could it be done any better so that I don't have to change the date in the source at all and it will itself change the where condition. I know it can be done with the help of a variable but can you explain me in detail of how to set up this step in my package. It would be a great help. Thanks.
Qry1.sql
0
Comment
Question by:Josh2442
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
PortletPaul earned 2000 total points
ID: 39176709
I'm going to offer an observation here: do NOT use "between"

as is:

rec_create_date between convert(varchar,'2009-1-01 00:00:00.000',102)
and convert(varchar,'2009-01-02 00:00:00.000',102)

to be:
(
rec_create_date >= convert(varchar,'2009-1-01 00:00:00.000',102)
and rec_create_date < convert(varchar,'2009-01-02 00:00:00.000',102)
)

as you are performing an import, you run the (small) risk of records being equal to a time of 00:00:00.000, and because you are using "between" then there is a (small) risk of duplication

The safest, most reliable, method is a combination of >= with < as indicated above.
(don't forget the parentheses)

You might regard the risk to low to bother, that's fine, but please just note that using "between" isn't best practice for date range filters.

for more on this topic please see: "Beware of Between"
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39176712
To your specific question about variables in SSIS, I suggest you try these:

https://www.simple-talk.com/sql/ssis/working-with-variables-in-sql-server-integration-services/

http://dataqueen.unlimitedviz.com/2012/08/how-to-set-and-use-variables-in-ssis-execute-sql-task/

These should answer everything you would need to implement variables in that import I believe.
0
 

Author Closing Comment

by:Josh2442
ID: 39191869
Thanks Expert
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In couple weeks ago, I encountered an extremely difficult problem while deploying 2008 SSIS packages to a new environment (SQL Server 2014 standard).  My scenario is: We have one C# application that is calling 2008R2 SSIS packages to load text fi…
Lessons learned during ten years of interviewing for SQL Server Integration Services (SSIS) and other Extract-Transform-Load (ETL) contract roles and two years of staff manager interviewing contractors.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question