how to delete from Table A based on Table B

lets say i have 100 employees on Table A and I have 10 employees on Table B. I want to delete all the employees in Table A that are in Table B. 

Delete From TableA Where EmpNum = (Select EmpNum From TableB)

The above SQL wont work but i am looking for something similar. any ideas?
0
renjitk
11/17/2005 11:52:02 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
505 Views

Similar Articles

[PageSpeed] 9

You should use IN as your subquery is returning multiple records.

Delete From TableA Where EmpNum IN (Select EmpNum From TableB)

***********************
Dinakar Nethi
Life is short. Enjoy it.
***********************
0
ndinakar
11/18/2005 12:10:53 AM
Reply:

Similar Artilces:

alter table of table A causes trigger on table B accesseng table A to fail
hi, i recently faced a strange problem, i have two tables, table A and table B table A has a update trigger which updates data in table B. i altered table B to add two more columns. after which when i updated table A(modifying 1 row), my tran log got full. there was a threshold proc which got fired but it did'nt help much. i though the tables had been corrupted. ran dbcc tablealloc on syslogs, table A, table B, no errors. Just to be sure I ran a dbcc checkdb, checkalloc and checkcatalog - no errors i recreated the trigger - no use. dropped the trigger. updated the table it ...

From Table to Table
I am working in Delphi 4 and ran into a roadblock I am unfamiliar with. I am trying to search and find values in one table based off of matching values in another. For example a table of objects with fields like name, description, type, ect; and a table of object properties in which each object can be represented multiple times based on the settings on the page at the time. So if i search the object property table (and eventually loop through to repeat for all objects) to find all cases of visible objects when a certain criteria is met. It stops on the first object with "Yes" in th...

Tables?! Why Tables?!
Bit random...but why does everything have to be rendered as a table?  It's starting to get quite annoying.  Formview - does this need to be a table?  the Menu??  Wouldn't it make sense to allow the option to...say...not render a Menu as a table?  Am I the only one that thinks this or are there others?  www.internetgeeks.co.ukwww.norwichbookclub.co.uk You can use CSS Adapters to create your own adapters to override how the controls render it self. In the next version of ASP.Net, you will probably have more flexibility to specify the surrounding elements of th...

how to transfer the data from table A to table B OR FROM EXCEL TO TABLE I NEED
Hi all,I am trying to transfer the data in the excel file to the SQL 2005 database .i am able to transfer the data into database, but into new table the table i need.can anybody help to transfer the whole data from the excel to the table i need or from one table to another.i would appreciate if anyone can help. TABLE A -----> TABLE BOREXCEL -----> TABLE I NEEDOR EXCEL ---->TABLE A -----> TABLE B  CheersDivikiran   right click database, select tasks-> import/export data ( depends on your requirements) select source and destination. (if from excel to ...

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. 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 time...

SQL call to count the total rows in Table B for each user in Table A
I have 2 tables:   TableA: Name UserA UserB UserC   Table B: Name               Data UserA              xxx UserB              asdasd UserB              ewrsad UserC              dsafasc UserA        &nbs...

accidentally deleted a table in my local SQL Server how can I get back the table
Hi, I accidentally deleted a table in my local server. How can I get back the table? I did not do it as a transaction! Thanks in Advance You need to restore back from your backup if available. There may be third party softwares that allow you to do such operations ... HTH, Vinod Kumar MCSE, DBA, MCAD, MCSD http://www.extremeexperts.com...

Deleting the master table withour deleting the child tables
Hi i have to delete the master table data without deleting the child table records,is there any solution for this,  parent table has relation with the child table. regards vinod.t.vSoftware EngineerUshustechTechnoparkTrivandrum India You need to temporarily disable constraints on the table. Disable constraints: ALTER TABLE MyTable NOCHECK CONSTRAINT ALL Enable constraints: ALTER TABLE MyTable CHECK CONSTRAINT ALL    If this post was useful to you, please mark it as answer. Thank you! Thanks johram i can try this solution, this is usefullSoftware Enginee...

.Net Code Generator based on SQL Server Tables
Hi, Not sure if I am posting at right forum but i was looking for a tool if avaliable which will read TABLE information from SQL Server Table and Generate .Net C# or VB.Net CLASS. e.g. For Customer table, it will create Properties for all the fields, and different generic class such as Create Customer, Change Customer, Delete Customer etc.   Is there any such tool available which can save developement time and we can always modify the code as need after generation of the code. Mainly will save time in defining datatype and diff. generic class...   Thanks  Thanks Codes...

I imported a SQL Table into SQL DataBase, But I can not update this table even with SQL Server management Studio
I imported a SQL Table into SQL DataBase, But I can not update this table even with SQL Server management Studio When I change any data on mentioned table above, Red exclamation sign appears left of the record . How can I correct this problem?  Thanks. Try running the UPDATE via Query Analyzer...and see if you get an error.***********************Dinakar NethiLife is short. Enjoy it.***********************...

a little help with transfering table A in Database A into table B in database B
I can't seem to find a good tutorial in transfering data from one table in database a into a different table in database b. The catch is that the fields in the tables don't match exactly. How can I do this? Examples, tutorials, etc are greatly appreciated.Thanks!Graphfixz Data & Web Designhttp://www.graphfixz.com All you need is INSERT INTO with column list that will give you control of how you the the insert into the new database, the other option was to use DTS.  Try the link below for the INSERT INTO statement.  Hope this helps.http://msdn.microsoft.com/library/def...

Showing table columns from multiple tables in Formview, but insert/update/delete rows of Master table
I have a page on which I have GridView and FomView control. On selection of a row in GridView the row gets displayed in the Item template of the FormVIew. The values are the result of inner join from multiple tables i.e. table Stock,Product and Workshop.  Please let me know how I could insert/update/delete data for the base table i.e. Stock table, but be able to see the column values from the associated tables on the Itemtemplate,Edittemplate and Inserttemplate of the FormView. Thanks,Anita Hi:   Take a look at this tutorial. It's for DetailsView and same ...

Wanting to take info from one SQL table and update to a seperate SQL table
Anyone have an idea of how I can take information from one table and edit it and insert into another SQL table.  I am using stored procedures and would like to continue to do so. Here is a copy of what I have so far:   <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="mp_Customers" SelectCommandType="StoredProcedure"></asp:SqlDataSource> </div> <h2><strong><font color="#C00000">Please enter a valid account number:</font></strong><...

T-Sql insert from table to table
Ok, need a little input on how to aproach this problem.Transfering data from one table to another.The first statement was easy...INSERT INTO myTable(ID)     SELECT ID      FROM someTableBut now, need to get the rest of the data - row by row.Selecting table columns:userID, objID0, objID1, objID2........ objID19 Also status 0 - 19, max 0 - 19Inserting table columns......userID, objID, courseID = "something not in selecting table",  status, maxAs you can see I am improving the database. (not my creation  )So, the selecting table r...

Web resources about - how to delete from Table A based on Table B - asp.net.sql-datasource

Delete key - Wikipedia, the free encyclopedia
, known less ambiguously as forward delete ) discards the character ahead of the cursor 's position, moving all following characters one position ...

Facebook Fined $77K by Argentine Court for Failing to Delete Alleged Defamatory Groups
... mess in Argentina , as PanAm Post reported that a Rosario court ordered the social network to pay compensation of $77,000 for failing to delete ...

Facebook adds search history to Activity Log so users can delete queries
... in users’ Activity Logs. The feature will be rolled out to all users in the next few weeks. The feature allows for users to view and delete ...

Tweets MPs Delete (@deletedbyMPs) on Twitter
Sign in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Tweets MPs Delete @ deletedbyMPs ...

Oren Jacob's answer to Pixar Animation Studios: Did Pixar accidentally delete Toy Story 2 during production ...
Oren Jacob's answer: Hi everyone, I'm the Oren Jacob in the video. Hopefully I can offer some first person color commentary about the video above ...

Tweeticide - Delete All of Your Twitter Tweets at Once! on the App Store on iTunes
Get Tweeticide - Delete All of Your Twitter Tweets at Once! on the App Store. See screenshots and ratings, and read customer reviews.

Delete, and I mean it! - Flickr - Photo Sharing!
I bought a new keyboard at work because I spilled cereal on the previous one and some of the keys stopped working. The new one has a giant delete ...

Facebook deletes Perth page dedicated to school fights
A page filled with videos of Perth school students fighting has been deleted by Facebook, as a video of people brawling in Perth CBD hit headlines. ...

Viber now lets you attach files, delete messages and more
... and public chat forwarding in late September , the app keeps growing. In an update today, Nov. 24, Viber users can now attach files, delete ...

Bank of America gets Twitter to delete journalist’s joke, says he violated copyright
The founding editor of Business Insider UK, Jim Edwards , had a bank delete two of his tweets today. In an e-mail, Bank of America told Edwards ...

Resources last updated: 12/28/2015 4:11:08 PM