declare @Col varchar(10)
declare @StrSQL varchar(200)--Step 1 Select Columns
select @Col = id from Table1 --where......(你自己写的条件最好是唯一的)--Step 2 Execute Sql Script
set @StrSQL = 'select' + @Col + 'from Tabel1'
exec @StrSQL
declare @StrSQL varchar(200)--Step 1 Select Columns
select @Col = id from Table1 --where......(你自己写的条件最好是唯一的)--Step 2 Execute Sql Script
set @StrSQL = 'select' + @Col + 'from Tabel1'
exec @StrSQL
select t2.*
from table2 as t2 join (
select name from syscolumns where id=object_id('table1')) as t1
on t1.name=t2.id
注意在表table1中只有f1...f10这10列,没有id,name...等等其它列名