Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS package to transfer today's record only 1

Status
Not open for further replies.

ezypezy80

Programmer
Apr 1, 2003
53
NZ
Hi
I have a DTS Package that I created in SQL Enterprise Manager.
It transfer data from an Excel spreadsheet to a SQL table.
It works fine , except I want to transer today's data only.

In the Excel spreadsheet I have a column called DATE yyyymmdd.
I want to transfer records where DATE = today, rather than all records.
How can I specify that criteria?

Thank you
 
In the SOURCE tab of your transformation task, change your source from table/view to sql query (there is a radio button).

I believe you can use sql queries on an excel sheet. Your query would be
Code:
select * from MySheetName where DATE >= dateadd(d, datediff(d, 0, getdate()), 0)

This part: dateadd(d, datediff(d, 0, getdate), 0)

Will remove time component from the date. If you want to exclude future dates as well, we will need to add a < piece.

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Thanks Alex, I will try that SQL command as well.

I was also playing with this command, if any of you guys are interested. It will filter all records with latest RunDate.

Code: SELECT * FROM MySheetName
WHERE (RunDate =(SELECT MAX(RunDate) AS MaxOfRunDate
FROM MySheetName))

 
That'll do it too :)

Nice work!

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top