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 2008 Forums
 Transact-SQL (2008)
 How to check my rows exists in another table?

Author  Topic 

nayanancha
Starting Member

27 Posts

Posted - 2012-03-01 : 10:05:21
I have a table variable with a column Role which has few rows

Role
------
Admin
Customer

I need to see whether these two rows exist in my aspnet_Roles tables which have the column RoleName

How to loop each of my rows from my table variable and see whether it exists in aspnet_Roles tables?

Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-01 : 10:19:26
SELECT * FROM aspnet_Roles WHERE RoleName IN (SELECT Role FROM @tbl)


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -