Showing posts with label destination. Show all posts
Showing posts with label destination. Show all posts

Sunday, February 19, 2012

Delete records that don exist in the destination

Hi all,

I am developing an ETL wherein the requirement is to do an incremental load and at the same time, if there is a record that got deleted in the Source delete it from the destination too, makes sense.

The approach am doing is, pick data from the SRC and Destination, pass it onto a Merge join component, do a Full Outer join, then pass the rows to a conditional split. Newly Added records and updated records I can handle, how do I handle the Deleted records?

Am I correct in the way I am doing or there is something better to handle this?

Thanks in advance

MShetty wrote:

Hi all,

I am developing an ETL wherein the requirement is to do an incremental load and at the same time, if there is a record that got deleted in the Source delete it from the destination too, makes sense.

The approach am doing is, pick data from the SRC and Destination, pass it onto a Merge join component, do a Full Outer join, then pass the rows to a conditional split. Newly Added records and updated records I can handle, how do I handle the Deleted records?

Am I correct in the way I am doing or there is something better to handle this?

Thanks in advance

That sounds like it will work. You basically need to compare the source and destination. Any records that are in the destination but not the source have to be removed - it sounds as if that is what you are attempting.

They can be deleted using an OLE DB Command. or you can push the records to be deleted into a temporary table and delete them using an Execute SQL Task.

-Jamie

|||

Hi Jamie,

Thx for the comments, I started working exactly the same way, but now am into an issue here. I am starting with two small tables as the first step. The table has this schema.

UserId (int) (PK)

UserName (varchar)

IsActive (bit) i am taking two DFT's one each to the two Databases and the selected records are passed onto a Merge Join. UserId is the join key here. Now the records that are having a match already are returned from this component right ? If I make the join type as a Ful Outer JOin and pass on to conditional split transform, how do I get the records that are in Destination DB but were deleted from the Source, I am just getting the newly added records and the updated one's. Please guide..

Thanks a lot

|||

I don't think you need a fullt outer join, just a left join will do it (with the incoming data on the left input).


Described here:

Get all from Table A that isn't in Table B
(http://www.sqlis.com/default.aspx?311)

-Jamie

|||

Thx for the inputs Jamie.

My problem of deleting the records in the destination that were removed from the Source DB was solved by using an IsNull (SrcTable.PK) in a conditional split and then direct those rows to an OLE DB Command Component.

delete records in the destination file in SSIS

How do I delete records in the destination file in SSIS using BI Development
Studio? Thanks.I mean I am running a daily task and I want to delete the records in destination DB or xls file before I export to this file. How can I do the delete task?|||Execute SQL Task for tables.

For Excel, I honestly don't know, but you might end up using a Script Task, where you use the Excel Object Model to empty the excel sheet.|||truncate table [table]. for sql

Delete records in destination table

Short Question: How do I delete all records from a destination table prior to appending new data to that table?

I am working with a SQL database that was migrated from MS Access. All relationships, primary keys, and identity columns have been set identically to the MS Access database values. The MS Access database is still being used as the database of record until the SQL database is fully functional with front-end, etc.

I want to delete the information stored in all the SQL tables, and then append the MS Access values to the SQL tables. I was able to write delete and append queries in MS Access to correctly transfer data to the SQL tables. However, I would prefer doing this through SSIS because I have several other sources of data to move to a SQL Server database and most of those other sources are not a MS Access database.

Due to relational entegrity settings, I need to delete the records from 8 tables in a specific order. I have tried independent control objects for each of the 8 tables with data flow objects of either "OLE DB Command" or "OLE DB Source" with the SQL command as "Delete From TableName". Results of the debug indicate everything is "green" but no records were deleted fromt the tables.

Maybe you could just generate scripts for the entire DB in Management Studio, and create a new database in SQLServer . You could use this new DB as the destination.

For the actual migration of data, you could use SSIS.

|||

Can't you just use an Execute SQL Task (or just use T-SQL through the management studio) and truncate the tables in the order of constraints?

Truncate Table a; Truncate Table b; etc...

|||

EWisdahl is correct. Use an Execute SQL to run the DELETE FROM statement, then your data flow after that.

Execute SQL -> DataFlow

delete records in destination file in SSIS

How do I delete records in the destination file in SSIS using BI Development
Studio?
Can anyone please help? Thanks.
" 00ScarlettJohnson" <EE@.yahoo.com> wrote in message
news:u68kNVyeHHA.2396@.TK2MSFTNGP04.phx.gbl...
> How do I delete records in the destination file in SSIS using BI
> Development Studio?
>
|||I mean I am running a daily task and I want to delete the records in
destination DB or xls file before I export to this file. How can I do the
delete task?
" 00ScarlettJohnson" <EE@.yahoo.com> wrote in message
news:u68kNVyeHHA.2396@.TK2MSFTNGP04.phx.gbl...
> How do I delete records in the destination file in SSIS using BI
> Development Studio?
>

delete records in destination file in SSIS

How do I delete records in the destination file in SSIS using BI Development
Studio?Can anyone please help? Thanks.
" 00ScarlettJohnson" <EE@.yahoo.com> wrote in message
news:u68kNVyeHHA.2396@.TK2MSFTNGP04.phx.gbl...
> How do I delete records in the destination file in SSIS using BI
> Development Studio?
>|||I mean I am running a daily task and I want to delete the records in
destination DB or xls file before I export to this file. How can I do the
delete task?
" 00ScarlettJohnson" <EE@.yahoo.com> wrote in message
news:u68kNVyeHHA.2396@.TK2MSFTNGP04.phx.gbl...
> How do I delete records in the destination file in SSIS using BI
> Development Studio?
>

delete records in destination file in SSIS

How do I delete records in the destination file in SSIS using BI Development
Studio?Can anyone please help? Thanks.
" 00ScarlettJohnson" <EE@.yahoo.com> wrote in message
news:u68kNVyeHHA.2396@.TK2MSFTNGP04.phx.gbl...
> How do I delete records in the destination file in SSIS using BI
> Development Studio?
>|||I mean I am running a daily task and I want to delete the records in
destination DB or xls file before I export to this file. How can I do the
delete task?
" 00ScarlettJohnson" <EE@.yahoo.com> wrote in message
news:u68kNVyeHHA.2396@.TK2MSFTNGP04.phx.gbl...
> How do I delete records in the destination file in SSIS using BI
> Development Studio?
>

Tuesday, February 14, 2012

delete last added row -how to

hi i have a question how can i delete last added row. I have 2 tables .
source and destination . I take a 1 row from source table , do some
operation on it and save to destination table . after succesfull written I
want to delete added row from source table.. i'm using a coursors. the main
problem is : is there any function to check which row was last added. Now I
am doing it using select * from destionation where (and necessary
conditions). but if destination table will be 100000000 rows for example it
takes too much time... Is there another possibility to do it ?
please help

Marcin Wolku
wolkuOne important think both tables don't have primary key

Uytkownik "Marcin Wolku" <wolku@.epf.pl> napisa w wiadomoci
news:42805b7b@.news.vogel.pl...
> hi i have a question how can i delete last added row. I have 2 tables .
> source and destination . I take a 1 row from source table , do some
> operation on it and save to destination table . after succesfull written I
> want to delete added row from source table.. i'm using a coursors. the
> main problem is : is there any function to check which row was last added.
> Now I am doing it using select * from destionation where (and necessary
> conditions). but if destination table will be 100000000 rows for example
> it takes too much time... Is there another possibility to do it ?
> please help
> Marcin Wolku
> wolku|||Unless you can identify the last inserted row by some column or columns
in the table you cannot delete that row. There is no special feature
for determining the insertion order.

The most important problem you have is the lack of a primary key. Why
don't you fix this? This is a fundamental design flaw as I hope you
know.

--
David Portas
SQL Server MVP
--