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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Deleting records from tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-03 : 10:39:55
Adrian writes "I have recently populated a table with records and i need to delete the recent records form the table. I would like to delete the records by date. e.g from 01/01/2004 to 01/04/04 (date is in small date time format) Can you knidly explain how to do it and possibly the SQL statement that i need to use."

gpl
Posting Yak Master

195 Posts

Posted - 2004-05-03 : 11:02:06
Adrian

Firstly, you should look up Books Online
Secondly, you want to use the delete command
I am assuming that you have a column on your table that holds the creation date, your SQL would look something like -

Delete MyTable
Where CreationDate Between StartDate and EndDate

-- if I am not 100% sure that I am deleting the corrct rows, I apply the where clause to a select to ensure that the returned rows are the ones I want to remove.

If you are saying that you want to delete the rows you added between those dates and there is nothing on the row to indicate when they were added, then Im afraid you are out of luck, unless you still have access to the source data that you inserted, in which case it might be possible to identify these rows and selectively delete them.

Graham
Go to Top of Page
   

- Advertisement -