Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kond.mohan
Posting Yak Master
213 Posts |
Posted - 2012-11-22 : 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 statementselect * 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 columnthanks |
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2012-11-22 : 10:20:04
|
delete from abc where timestamp between dateadd(day,-3,getdate()) and getdate() |
|
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2012-11-22 : 10:40:28
|
second thoughtsyou'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
213 Posts |
Posted - 2012-11-23 : 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 samplesthanks |
|
|
|
|
|