Solved

Deleting SQL Data

Posted on 2014-02-21
2
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

626 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