| Author |
Topic  |
|
|
kond.mohan
Posting Yak Master
India
154 Posts |
Posted - 11/22/2012 : 08:34:34
|
Dear all we are fething the from orcle to sql server loading on daily basis.(incremental process) here i am fetching the last 2 days records based on thethis sql statement
select * from abc where timestamp >=SYSDATE-3--1200 records are loaded(using ssis package source and destination)
here we need to delete the timestampcolumn-3 days records i have provided below delete statement this is effetcing 0 records
DELETE FROM abc WHERE TIMEstamp =timestamp-3 (means last 3 days)
pls provide the way how to delete based on timestamp column
thanks
|
Edited by - kond.mohan on 11/22/2012 08:36:25
|
|
|
masterdineen
Aged Yak Warrior
United Kingdom
522 Posts |
Posted - 11/22/2012 : 10:20:04
|
| delete from abc where timestamp between dateadd(day,-3,getdate()) and getdate() |
 |
|
|
masterdineen
Aged Yak Warrior
United Kingdom
522 Posts |
Posted - 11/22/2012 : 10:40:28
|
second thoughts you'd better use this one.
delete from abc where timestamp between dateadd(day, datediff(day, 0, (getdate())), -3) and dateadd(day, datediff(day, 0, (getdate())), -0)
that way you will include all records on the three days instead of exactly 3 days
|
 |
|
|
kond.mohan
Posting Yak Master
India
154 Posts |
Posted - 11/23/2012 : 02:49:34
|
dear masterdineen thx for your reply, case 1. source table having modified then we need to follow the modified_date column for fetching the data . case 2. source table doesn't have the modified_date column in this case which way we need to follow the fetch incremental data pls provide the samples
thanks |
 |
|
| |
Topic  |
|