Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
If the user want to archive data older than 30 than @numberofDay should convert into date like 11/03/2013.They want to pass in days as int and the process should convert that into day.Any help would greatly appreciate.Declare @NumberofDay INT = 30-- No@NumberofDay should be something like '11/03/2013'DELETE FROM MyBillingOUTPUT deleted.[__$start_lsn], deleted.[__$seqval], deleted.[__$operation], deleted.[__$update_mask], deleted.[BillingDetail_ID] INTO ArchiveAudit.MyBilling_CT ( [__$start_lsn], [__$seqval], [__$operation], [__$update_mask], [BillingDetail_ID] WHERE (CONVERT(CHAR(8), [Effective_date], 112) < @NumberofDay ) -- This some how become '11/03/2013'
TG
Master Smack Fu Yak Hacker
6065 Posts
Posted - 2013-12-03 : 17:28:03
Do you want a date that is @numberofDays less than today?
WHERE Effective_date < dateadd(day, datediff(day, 0, getdate()), -@numberOfDay)
Be One with the OptimizerTG
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2013-12-03 : 23:43:38
quote:Originally posted by NguyenL71 If the user want to archive data older than 30 than @numberofDay should convert into date like 11/03/2013.They want to pass in days as int and the process should convert that into day.Any help would greatly appreciate.Declare @NumberofDay INT = 30-- No@NumberofDay should be something like '11/03/2013'DELETE FROM MyBillingOUTPUT deleted.[__$start_lsn], deleted.[__$seqval], deleted.[__$operation], deleted.[__$update_mask], deleted.[BillingDetail_ID] INTO ArchiveAudit.MyBilling_CT ( [__$start_lsn], [__$seqval], [__$operation], [__$update_mask], [BillingDetail_ID] WHERE (CONVERT(CHAR(8), [Effective_date], 112) < @NumberofDay ) -- This some how become '11/03/2013'