日期:2014-05-17 浏览次数:20480 次
declare @ab varchar(1)
select @ab= case when bh = '1' then 'table1' else 'table2'
select bh,mc from @ab
/*我这么写 执行的时候提示 没有@ab 表*/
declare @bh varchar(1000)='1'
declare @ab varchar(1000)
select @ab= case when @bh = '1' then 'table1' else 'table2' end
Exec('select bh,mc from '+ @ab)
declare @ab varchar(10),@tsql varchar(6000)
select @ab=case when bh='1' then 'table1' else 'table2' end
select @tsql='select bh,mc from '+@ab
exec(@tsql)