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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Delete records

Author  Topic 

rana8689
Starting Member

2 Posts

Posted - 2006-10-09 : 19:47:39
There are 30 tables in my database and I need to delete all records within a date range. Could anyone help me?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-10-09 : 19:58:22
DELETE FROM Table1 WHERE SomeDateColumn BETWEEN '01/01/2006' AND GETDATE()
DELETE FROM Table2 WHERE SomeDateColumn BETWEEN '01/01/2006' AND GETDATE()
...

Tara Kizer
Go to Top of Page

rana8689
Starting Member

2 Posts

Posted - 2006-10-09 : 22:33:50
Is there a single line code for the full data base?
Or is there a code to delete all the data in the database.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-09 : 23:10:58
quote:
Originally posted by rana8689

Is there a single line code for the full data base?
Or is there a code to delete all the data in the database.


No.

You can script out all the objects in the database, BACKUP the database, drop it, create a new database and apply the scripts.


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-09 : 23:14:04
or try the script below
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65341



KH

Go to Top of Page
   

- Advertisement -