declare @columns1 VARCHAR(max)
select
@columns1=coalesce(@columns1 + ', ', '') + ('tbl1.' + cast(tA1.column_name AS varchar(100)))
from (
select * from table_field_name
where table_name='table1'
) as tA1
inner join
(select table_name, column_name from (
select * from table_field_name
where table_name='table2'
) as ta) tA2
on tA2.column_name=tA1.column_name
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment