Click here to Skip to main content
15,898,588 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to select the unique column names from different tables using join without use of table alias in sql server 2008
Declare @SelectClause varchar(max);
set @SelectClause ='column1,column2,column3';
Declare @qry varchar(max);

set @qry= 'Select ' + @SelectClause  + ' from table1 acc with(Nolock) join table2 ic with(Nolock) on acc.column1=ic.column1 '
execute(@qry)

here column1 and column2 both are in table1 as well as table2

waiting for your reply.
Thanks, In advance.
Posted
Updated 8-Jun-11 0:12am
v2
Comments
[no name] 8-Jun-11 6:09am    
did you google it?

1 solution

SQL
Use EXISTS like:
Code Snippet
select *
from t1
where exists(select * from t2 where t2.col1 = t1.col1 and t2.col2 = t1.col2 ...)
 
Share this answer
 
Comments
mansoorttg 26-May-12 3:00am    
how to use with 4 tables
[no name] 28-May-12 0:55am    
can you elaborate the condition to use this with 4 tables?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900