Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
hussainzim
Starting Member
21 Posts |
Posted - 2007-09-24 : 20:12:52
|
| Table Strucure - : TestEven(TestNo,EmpNo,TestDate)I jst want to write a stored procedure to delete all data which is 2 years old. thank you in adavance.Hussain |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-09-24 : 20:23:44
|
| DELETE FROM TestEven WHERE TestDate <= DATEADD(y, -2, GETDATE())Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-09-24 : 21:26:46
|
| Do a SELECT before the DELETE for the same condition and check how many records get deleted. IF its into hundreds of thousands of rows you might want to batch it.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
hussainzim
Starting Member
21 Posts |
Posted - 2007-09-25 : 04:06:05
|
| thanks.... |
 |
|
|
|
|
|