Hello all,
A little question regarding SQL Server DB's.
I have a two tables containing customers invoices, one for the invoices header (ie: customer #, invoice date,... KEY: invoice # + invoice date) and another for the details of the invoices (ie: each invoice line details KEY: invoice # + line #). I need to periodically remove invoices older than a certain timeframe (ex: all invoices older than 48 months).
How can I proceed?
I am fairly new with SQL server... Please help!
Thanks,
Eric
:(Set up a cascading delete relationship between your invoices table and your invoice lines table. Then run this statement:
delete
from Invoices
where InvoiceDate < dateadd(months, -48, getdate())
Look up the dateadd function in Books Online to verify the syntax above.|||Skunked again.
Saturday, February 25, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment