MorphuisOGrady
Member
Hi Guys,
I'm not much of a SQL person so I was hoping for a digout on the correct way to approach this...
I am logging data to multiple SQL databases via ODBC from datalog models in FTView. The data I use to generate daily reports using Microsoft Reporting services.
What I have discovered:
- FTView does not purge the database as expected.
-If I use SQL queries to delete data older than 90 days the database does not shrink despite the Auto shrink feature turned on in SQL Management Console.
My question is as follows:
If I use the WIndows Task scheduler to run a batch file which executes SQL queries to delete the data can I run a shrink in the same script or must I wait. If i do from the Management console it might take 20 seconds to delete the data.
USE TRENDS_DB;
DELETE FROM dbo.FloatTable
WHERE DateAndTime < GETDATE()-60;
USE STATS_DB;
DELETE FROM dbo.FloatTable
WHERE DateAndTime < GETDATE()-90;
Can I add this code immediately after?
DBCC SHRINKDATABASE (TRENDS_DB, 10);
GO
I'm not much of a SQL person so I was hoping for a digout on the correct way to approach this...
I am logging data to multiple SQL databases via ODBC from datalog models in FTView. The data I use to generate daily reports using Microsoft Reporting services.
What I have discovered:
- FTView does not purge the database as expected.
-If I use SQL queries to delete data older than 90 days the database does not shrink despite the Auto shrink feature turned on in SQL Management Console.
My question is as follows:
If I use the WIndows Task scheduler to run a batch file which executes SQL queries to delete the data can I run a shrink in the same script or must I wait. If i do from the Management console it might take 20 seconds to delete the data.
USE TRENDS_DB;
DELETE FROM dbo.FloatTable
WHERE DateAndTime < GETDATE()-60;
USE STATS_DB;
DELETE FROM dbo.FloatTable
WHERE DateAndTime < GETDATE()-90;
Can I add this code immediately after?
DBCC SHRINKDATABASE (TRENDS_DB, 10);
GO