Solved

Deleting SQL Data

Posted on 2014-02-21
2
181 Views
Last Modified: 2014-02-21
I would like to know if there is a way that I can automate SQL data to be deleted.  Maybe once the database reaches a certain size then delete X amount or something like this.  I really don't know SQL and have 100's of servers that are running out of space from SQL databases.
0
Comment
Question by:MicahMcC
2 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 39878418
There are some ways to make space without deleting any data, eg shrinking them, deleting logs.

DBCC SHRINKDATABASE is one.

If you are sure you can delete data, use DELETE queries, eg

DELETE FROM table WHERE somedatefield<DateAdd(year,-5, Getdate()) 

Open in new window

Would delete data older than 5 years according to somedatefield.

If you don't have datetime data in your table you won't be able to judge it's age, you will need to define the conditions for unimportant data differently, then.

Bye, Olaf.
0
 

Author Closing Comment

by:MicahMcC
ID: 39878438
Olaf, thank you for the speedy response.  This will work as currently the servers that are filling up have approximately 4-7 years’ worth of data on them.  Thank you again!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to union three related tables in one flat file? 8 48
sql server query 18 41
Help With SQL Query 9 33
Getting invalid Syntax SQL. 3 21
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question