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)
Use EXISTS like: Code Snippet select * from t1 where exists(select * from t2 where t2.col1 = t1.col1 and t2.col2 = t1.col2 ...)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)