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
 General SQL Server Forums
 New to SQL Server Programming
 Loop to search for values in a table

Author  Topic 

Martina
Starting Member

1 Post

Posted - 2008-11-04 : 05:39:31
I have two tables in SQL Enterprise. I need to check if the data in the first table is contained within the second table

I need to take the data based on a combination of two column values in the first table and check if they are in the second table. Is a loop the best way to do this. A simple example would be appreciated.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-04 : 05:48:42
Select * from table as t1 where exists(select * from table2 where col1=t1.col1 and col2=t1.col2)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -