I'm importing data from txt
to Sql Server table
. That part works good.
Everyday this txt
file is being deleted and new txt
file is formed (i.e. yesterday there was data for 3 February, today for 4 February (column Date
)).
When I run package, I want it to check whether Date
column exists in database table. If it exists, skip, don't import, if it doesn't - import. And I want to save that Date value in a variable
for further manipulations. How can I accomplish that?
we suppose you have your source file with the format and data as bellow
id | product | dateLoad
1 | dell | 25-01-2016 16:23:14
2 | hp | 25-01-2016 16:23:15
3 | lenovo | 25-01-2016 16:23:16
and your destination have the format as bellow
create table stack(id int,product varchar(20),dateLoad smalldatetime);
In your SSIS
add a Derived Column
to convert the smalldatetime
to date
like this :
Secondly add a Lookup
in General
Tab in your Lookup transformation Editor
go to Specify how to handle rows with no matching entries
and select Redirect rows to no match output
. In Connection
Tab add a connection to target table
and i wrote a Sql query
to convert the smalldatetime to date
show the picture as bellow :
Finally add a connection with the lookup
and your target table
and select Lookup no matching output
In the first execution i have 3 rows
inserted because i don't have the date in my table
I execute another time but i had 0 rows
because i have the date in my table
I hope that help you