如下语句: declare @s int declare @n char(10) set @s =(select min(id) from zhtj_table) set @n=(select name from zhtj_table where id=@s) select sum(times) from @n 执行后提示:必须声明变量 '@n'。 为什么?
测试过了: declare @s int declare @n char(10) set @s =(select min(id) from zhtj_table) set @n=(select name from zhtj_table where id=@s) exec('select sum(times) from '+@n)