I'm having trouble deleting data, which is causing the log drive to fill up, how can I delete in batches adding a loop? Thanks
DELETE FROM [POSStoreInventoryDev].[dbo].[MessageHeader] where TransactionDateTime < DATEADD(DD,-7,GETDATE() )
DELETE FROM [POSStoreInventoryDev].[dbo].[MessageLocationAvailability] where TransactionDateTime < DATEADD(DD,-7,GETDATE() )
If you have log space to delete one day's worth at a time, then do this:
DELETE FROM [POSStoreInventoryDev].[dbo].[MessageHeader] where
TransactionDateTime >= DATEADD(DAY, -7, CAST(GETDATE() AS date)) AND
TransactionDateTime < DATEADD(DAY, -6, CAST(GETDATE() AS date))
DELETE FROM [POSStoreInventoryDev].[dbo].[MessageHeader] where TransactionDateTime >= DATEADD(DAY, -6, CAST(GETDATE() AS date)) AND TransactionDateTime < DATEADD(DAY, -5, CAST(GETDATE() AS date))
DELETE FROM [POSStoreInventoryDev].[dbo].[MessageHeader] where TransactionDateTime >= DATEADD(DAY, -5, CAST(GETDATE() AS date)) AND TransactionDateTime < DATEADD(DAY, -4, CAST(GETDATE() AS date))
DELETE FROM [POSStoreInventoryDev].[dbo].[MessageHeader] where TransactionDateTime >= DATEADD(DAY, -4, CAST(GETDATE() AS date)) AND TransactionDateTime < DATEADD(DAY, -3, CAST(GETDATE() AS date))
/*...*/