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 2005 Forums
 Transact-SQL (2005)
 How to Delete certain rows from a database

Author  Topic 

krista80
Starting Member

29 Posts

Posted - 2011-01-31 : 09:45:45
Hi. I want to delete rows from one table that match rows in another table. How do I do this? My current query syntax looks like this:

DELETE FROM table2
WHERE EXISTS
(SELECT * FROM Results as r, Information as i
WHERE
r.firstColumn = i.firstColumn
AND r.secondColumn = i.SecondColumn)

Any help?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-01-31 : 09:48:26
Please give table structure, example data and wanted result.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

krista80
Starting Member

29 Posts

Posted - 2011-01-31 : 10:00:21
I have two tables, both with two columns that just have 3 numbers in each. I have loaded both tables with 5 rows of information. 3 rows have different information in each table, and two rows have the same information. I want to delete the 2 rows of matching information. All columns are set to varchar(MAX) and they don't allow nulls.
Go to Top of Page

krista80
Starting Member

29 Posts

Posted - 2011-01-31 : 10:22:12
I figured it out. Sorry for any inconvenience.
Go to Top of Page
   

- Advertisement -