declare @test2 varchar(100)
set @test2='select getdate() where 1 =1'
select * from (@test2)
------解决方案--------------------
declare @test2 varchar(100)
set @test2='select getdate() from tablename where 1 =1'
exec(@test2)
declare @test2 varchar(100)
set @test2='select getdate() from tablename where 1 =1'
exec(@test2)