473,671 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to delete a table with about 2000 rows

vanc
211 Recognized Expert New Member
I'm trying to delete a table with just around 2000 rows. What I got is timeout error. I can't use Truncate Table, which is very quick, because I have Trigger with Delete command.
Is there any way to increase timeout "time" in sql server to let my query finish? Or there is better way to do this. Any comment will help.

Expand|Select|Wrap|Line Numbers
  1. My query is just this
  2.  
  3. Delete From aTable
  4.  
  5.  
Dec 18 '07 #1
2 1667
Jim Doherty
897 Recognized Expert Contributor
I'm trying to delete a table with just around 2000 rows. What I got is timeout error. I can't use Truncate Table, which is very quick, because I have Trigger with Delete command.
Is there any way to increase timeout "time" in sql server to let my query finish? Or there is better way to do this. Any comment will help.

Expand|Select|Wrap|Line Numbers
  1. My query is just this
  2.  
  3. Delete From aTable
  4.  
  5.  
You could temporarily disable your trigger to allow for the truncation process nd re-enable it?


Expand|Select|Wrap|Line Numbers
  1.  
  2. ALTER TABLE yourdatabasename.dbo.yourtablename disable trigger yourtriggername
  3.  
  4. truncate table yourtablename
  5.  
  6. ALTER TABLE yourdatabasename.dbo.yourtablename enable trigger yourtriggername
  7.  
Jim :)
Dec 21 '07 #2
iburyak
1,017 Recognized Expert Top Contributor
You might want to try this:

Expand|Select|Wrap|Line Numbers
  1. SET ROWCOUNT 1000
  2. go
  3. while (select count(*) from table_name) > 0
  4. BEGIN
  5.    begin tran 
  6.     delete from table_name
  7.    commit tran
  8. END
  9. go
  10. SET ROWCOUNT 0
  11.  
Good Luck.
Dec 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
6453
by: Gordon | last post by:
I have 2 tables t and t1. In this case, t1 is a copy of t. I want to delete rows from t1 based on criteria on the t table and a relationship between t ad t1 (in this case the id column). In the results below, I would think that the delete should have deleted row 1 {1 5 me) and not row 3 (1 5 they) when I run this statement delete t1 from t, t1 where t.id = t1.id and t.id=1 and t.name = 'me'; Any ideas on why row 2 is deleted?
1
3847
by: Simon Withers | last post by:
I am using a sql server 2000 database to log the results from a monitor that I have running - essentially every minuite, the table described below has a insert and delete statements similar to the ones below run againt it. Everything is fine for a few weeks, and then without fail, all accesses to the table start slowing down, to the point where even trying to select all rows starts timing out. At that point, the only way to make...
2
11793
by: Bob Ganger | last post by:
Hello, I am working on a project using SQL Server 2000 with a database containing about 10 related tables with a lot of columns containing text. The total current size of the database is about 2 Gig. When I delete data from the database, it takes a lot of system resources and monopolizes the database so that all other query requests are slow as mud! Ideally, I would like to be able to issue delete commands to the database on a...
4
1998
by: akej via SQLMonster.com | last post by:
Hi, suppose i have 3 tables main table CREATE TABLE table1 ( primary key , nvatchar(50) NOT NULL, ............................ )
16
3867
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the table, or perhaps bytes, being updated where the engine just decides, screw it, i'll just make a new one. surfed this group and google, but couldn't find anything. the context: we have some java folk who like to parametize/
9
3577
by: nnelson | last post by:
I have a base customer table of 2 million records. We're doing some testing and I added 33000 rows incorrectly. No biggie, we'll just delete them, right? Nope....9 hours later, process is still running using this query. delete from customer where custid in (select custid from #tmp1) k...so we'll change it. delete from customer where custid > 2295885
9
2790
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like this: id Name Surname pictr0 picrt1 pictr2 pictr3
5
9923
by: Neil | last post by:
I am getting time-out errors when I try to perform a simple delete on a linked server. The command is: Delete From MyTable Where PKID=12345 I have tried executing this command directly from Query Analyzer, but it just times out. However, when I run it from QA against the server itself (rather than from my local server against a linked server), it executes immediately. Similarly, if I run the same SQL command through an ODBC linked...
3
12323
by: Michel Esber | last post by:
Hello, Environment: DB2 LUW v8 FP15 / Linux I have a table with 50+ Million rows. The table structure is basically (ID - Timestamp). I have two main applications - one inserting rows, and the other reading/deleting rows. The 'deleter' application runs a MIN/MAX (timestamp) for each ID and, if the difference between min/max is greater than 1h, it reads all
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8603
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.