Deleting rows from one table based upon rows in another table

I need to delete rows from table1 based on rows in table2.
table1 has 1.5 million rows from which I need to delete
20,000 existing in table2. The table structures are the same
and I must exactly match 10 (of the 15) columns in the
tables. I also need to limit the number of rows being worked
on, in a single transaction, to 500 or so.
0
Mike
1/19/2004 11:33:09 AM
sybase.ase.general 8655 articles. 0 followers. Follow

1 Replies
1072 Views

Similar Articles

[PageSpeed] 9

Hi Mike,
try the following:

set rowcount 500
DELETE table1
from table1 t1,table2 t2
where t1.col1=t2.col1 and t1.col2=t2.col2 and t1.col3=t2.col3 and ........
t1.col10=t2.col10

HTH.
Regards
P:S You must re-execute the DML statement above 40 times to delete 20,000
rows
ALPER ONEY
SYBASE DBA
I.S.E TAKASBANK INC
TEL:+902123152109

<Mike Watson> wrote in message news:400bc2b1.2602.846930886@sybase.com...
> I need to delete rows from table1 based on rows in table2.
> table1 has 1.5 million rows from which I need to delete
> 20,000 existing in table2. The table structures are the same
> and I must exactly match 10 (of the 15) columns in the
> tables. I also need to limit the number of rows being worked
> on, in a single transaction, to 500 or so.


0
ALPER
1/19/2004 11:44:36 AM
Reply:

Similar Artilces:

Select rows from a table based on multiple rows of another table
I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. ...

Select rows from a table based on multiple rows of another table #4
I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. ...

Select rows from a table based on multiple rows of another table #2
I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. Sorry technical problems! I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. I have a table which holds all of my project info and I have another table which holds discriptive project codes like project type, project category, progect life cycle.So in the pro...

Select rows from a table based on multiple rows of another table #3
I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. ...

Update a rows in one table for each row in other table
Hello all, i am a newbie in SQL and i want to ask for your help in order to do the following update statement. I have a table tblUsers which holds all the users, one of the fields in their GroupId. In the UserGroup table i have a field "UsersCount" and in that field i want to keep the number of the users in that group. Basically i want everytime i am saving a user to recalculate the users in all usergroups. I am trying to have something like:SELECT User_GroupId, count(User_GroupId) as UsersCount FROM tblUsersWHERE DeletedFlag = 0 GROUP BY User_GroupId and then:"FOR EACH" User_GroupIdUPDAT...

How to change the Rows of the one table to another table
I want's to change the layout of my table at run time on the basis of some of my Setting File[I don't want's to use webpart orwebzones]Suppose I have three Tables with number of rows.[In reality Each row will contain some controls]On Page_Preinit I want's to set the rows of one table to another also want's to change order of the rows.How Can I do that ?  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/...

Stored Procedure that fetch each row of a table and update rows in another table
I am working with the following two tables: Category(NewID,OldID) Link(CategoryID,BusinessID) All fields are of Integer Type. I need to write a stored procedure in sql 2000 which works as follows: Select all the NewID and OldID from the Category Table (SELECT NewID,OldID FROM Category) Then for each rows fetched from last query, execute a update query in the Link table. For Example, Let @NID be the NewID for each rows and @OID be the OldID for each rows. Then the query for each row should be.. UPDATE Link SET CategoryID=@CID WHERE CategoryID=@OID Please help me ...

Copying html table rows from one table to another.
Hi Im am trying to copy table rows from one html table to another. Below is a one of my many attempts and all this does is moving the rows from the one table to the other. I would appreciate any help. int iCount; HtmlTableRow[] TableRows = new HtmlTableRow[Table1.Rows.Count]; Table1.Rows.CopyTo(trs,0); for (iCount = 0; iCount < TableRows.Length; iCount++) { Table2.Rows.Add(TableRows[iCount]); } Thanks ...

Need to transfer certain rows from one table into another table
On my online store, I need to figure out with sql how I can copy data from several different tables into another table: There is a table that contains all of the customers billing infoanother table has customer's shipping info The target table is for tracking and processing orders.  I will need to populate different fields from different tables, as well as insert values into fields from my code behind (i.e. customers can choose different types of shipping, payment options).  I googled this and keep running into the join statement (which I use all the time).  I don't ...

Stored Procedure
I wish to select all post from Table Category and the first row in Product table. SQL goes (not working just to show you how im thinking): SELECT Category.CategoryID, Category.Title, TOP (1) Product.ImagePath, TOP (1)  Product.CategoryID FROM Category INNER JOIN Product ON Category.CategoryID = Product.CategoryID GROUP BY Category.CategoryID, Category.Title Thanks for your help!  SELECT Category.CategoryID, Category.Title, Product.ImagePath,   Product.CategoryID FROM Category crossJOIN (select top 1 * from  Product ) PGive a man a fish and you feed him for ...

Record from one table, calcs on each row of another table
Imagine two tables. Table 1 has various tombstone information, including Latitude and Longitude. Table 2 has a bunch of locations, each with a latitude and longitude. I've created a class for various geomaths; in this case, distance between two GPS coords, and bearing from point A to point B.  Set startlat, startlong, endlat, endlong, and read distance and bearing properties, the class does the maths.  So, what I want to do is read a record from Table 1; this record is displayed, at the moment, in a DetailsView. I want to read each record from table 2, calculate the distan...

selecting one row and inserting it into another table one by one
i ve a table named "Employee" in wh i ve fields "Emp_Id","Name" and "Email". i want to select each employee "Emp_Id" one by one from "Employee" table and insert it into another table named "Concerned_Department". like if i ve three rows in "Employee" table with "Emp_Id" 1,2 and 3 respectively,in this case i want to first select "Emp_Id"=1 then "Emp_id"=2 and lastly "Emp_id"=3 and insert them into "Concerned_Department"table.  after that the process star...

Update row in Table A from row in Table B
Hello, I have 2 tables.... table A and table B. Ok, In a stored procedure, I pass in an int value @ID I want to get the row from Table B WHERE ID =@ID....and then UPDATE the Row in Table A that has the same ID...with the values from table B. Table A ID | Col1 | Col2 ----------------------- 2 a a Table B ID | Col1 | Col2 ----------------------- 2 b b I would like to update A.Col1 with B.Col1 and A.Col2 with B.Col2 Can someone help me out with this syntax? Thanks a lot. update tableA ...

Add row to table with table.row.add()
Everytime I click on a button I want to add a tableRow to a table like this:        TextBox TB = new TextBox();                TableCell Cell = new TableCell();        Cell.Controls.Add(TB);        TableRow Row = new TableRow();        Row.Cells.Add(Cell);        table.Rows.Add(Row);It works the first time, but when I click the button again the last r...

Web resources about - Deleting rows from one table based upon rows in another table - sybase.ase.general

Deleting Online Predators Act of 2006 - Wikipedia, the free encyclopedia
( DOPA ) is a bill ( H.R. 5319 ) brought before the United States House of Representatives on May 9, 2006 by Republican Pennsylvania Representative ...

Facebook Deleting Inflammatory Content In India
Facebook has been complying with a request by the government of India and removing “inflammatory and hateful content” that has caused tens of ...

Deleting your Facebook page is foolish
... brag, trailing closely behind that fantastically annoying “I don’t even have a TV , never mind watch the drivel!” Let’s lay it out: deleting ...

AdWords Campaign Experiments: Applying or deleting your experimental changes - YouTube
To improve your AdWords experience, we're testing a new tool that helps you optimize your account. AdWords Campaign Experiments, or ACE, does ...

Deleting abusive online content a 'near impossible' task
POSTING offensive, harassing, intimidating or defamatory content online takes mere seconds, but getting it removed can take what feels like a ...

Paleo advocate Pete Evans accused of deleting critical posts on Facebook
Is Paleo Pete Evans is open to dietary debate? Some say he's not.

Microsoft on the threshold of deleting 'appalling' Windows 8 software
MICROSOFT plans to cut its losses on Windows 8, the latest version of the software that runs the majority of the world's computers, jettisoning ...

How to get iOS 8 without deleting everything on your phone
If you've tried downloading iOS 8, or know anyone who has already done so, you're probably familiar with the biggest complaint: The download ...

Dalton McGuinty staffers broke law by deleting gas plant emails
Senior staff members in the offices of both the Ontario energy minister and former premier Dalton McGuinty intentionally deleted emails about ...

Jason Kenney under fire for praising ‘perfect, unaccented English’, deleting tweet
Canada's Minister for Multiculturalism, Jason Kenney, caused an upset Monday after praising an 11-year-old Iraqi refugee who "already speaks ...

Resources last updated: 12/7/2015 8:01:39 AM