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)
 BIG delete query

Author  Topic 

mdelgado
Posting Yak Master

141 Posts

Posted - 2002-12-10 : 11:12:26
hello all...

I'm currently running a delete query on a very big table with indexes. THe delete query is going on 2 1/2 hours now. I notice the transaction log is growing very quickly. My question is, can I run a delete query and have sql not write to the transaction log? Kind of like a 'truncate table' does not write to the log..

thanks.

mr_mist
Grunnio

1870 Posts

Posted - 2002-12-10 : 11:18:59
Maybe you could BCP the rows you want to keep in the table out of the database, truncate the table, then BCP the data back in.

-------
Moo.
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-12-10 : 11:20:06
You can copy the rows you want to keep into a table variable.
Run Truncate on the table and then copy the rows back in.
This method will still log the rows that you keep.





Edited by - ValterBorges on 12/10/2002 11:24:08

Edited by - ValterBorges on 12/10/2002 11:24:35
Go to Top of Page

royv
Constraint Violating Yak Guru

455 Posts

Posted - 2002-12-10 : 12:28:08
you did not mention what version you are running, if you try valterborges's method, you will have to have sql 2000

***************************************
Death must absolutely come to enemies of the code!
Go to Top of Page

mdelgado
Posting Yak Master

141 Posts

Posted - 2002-12-10 : 12:28:57
I have sql2k...

Still struggling with this...

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2002-12-10 : 12:43:16
You should drop the indexes before performing the delete. After the delete, recreate the indexes. This should speed up your query tremendously. Just keep in mind that if someone is accessing this table, then their queries will be table scans because no indexes will exist. But then again, your query is probably blocking everyone anyway.

Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-12-10 : 12:43:27
What exactly are you struggling with.

Go to Top of Page
   

- Advertisement -