SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Delete From Scripting Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ostinoh
Yak Posting Veteran

66 Posts

Posted - 07/23/2013 :  12:12:48  Show Profile  Reply with Quote
Hello –
I currently have an SSIS package running and the first part of it deletes all data in (Table A) but saves the rows with the PIT of Friday at 4:00 PM for reference reasons.

DELETE FROM dbo.BackLogLaborOld
WHERE (datename(dw,PIT)<>'Friday' or datepart(hh,PIT) <> 16)

Now they want to change the day and time to Saturday at 12:00 PM to save but don't want to have the script delete all data from the past Friday’s at 4:00 PM data.

So I want to save the old Friday data but going forward change to the new day and time.

Could anyone suggest how I would go about doing that? Is that possible?

Regards,
David

James K
Flowing Fount of Yak Knowledge

3760 Posts

Posted - 07/23/2013 :  13:05:40  Show Profile  Reply with Quote
Like this:
DELETE FROM dbo.BackLogLaborOld
WHERE (datename(dw,PIT)<>'Saturday' or datepart(hh,PIT) <> 12)
AND PIT > '20130722';
That 'Saturday' is language dependent, so if you have any need for internationalization/localization, instead of datename(dw,PIT)<>'Saturday' use DATEDIFF(dd,0,PIT)%7 <> 5
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 07/24/2013 :  01:32:26  Show Profile  Reply with Quote
quote:
Originally posted by ostinoh

Hello –
I currently have an SSIS package running and the first part of it deletes all data in (Table A) but saves the rows with the PIT of Friday at 4:00 PM for reference reasons.

DELETE FROM dbo.BackLogLaborOld
WHERE (datename(dw,PIT)<>'Friday' or datepart(hh,PIT) <> 16)

Now they want to change the day and time to Saturday at 12:00 PM to save but don't want to have the script delete all data from the past Friday’s at 4:00 PM data.

So I want to save the old Friday data but going forward change to the new day and time.

Could anyone suggest how I would go about doing that? Is that possible?

Regards,
David


its possible if you've a batchid which indicates the batch which processed the records. Or you could also capture this information if you've an audit or control table setup which logs details on each package processed records.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

ostinoh
Yak Posting Veteran

66 Posts

Posted - 07/24/2013 :  12:08:18  Show Profile  Reply with Quote
Thank you all for the responses. I will try and post with my results when we try it out.

Regards,
David
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 07/25/2013 :  00:48:56  Show Profile  Reply with Quote
quote:
Originally posted by ostinoh

Thank you all for the responses. I will try and post with my results when we try it out.

Regards,
David


welcome
let us know how you got on

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000