±ÈÈçÕâÀïµÃµ½Ò»¸ö±í£ºexec('select * from student where ÐÕÃû='''+@name+'''')£¬ÎÒÔõô°ÑÕâ¸ö±íµÄÊý¾Ý²åÈëµ½Ò»¸öÁÙʱ±íÀ insert #tab select exec('select * from student where ÐÕÃû='''+@name+'''')Õâ¸öÔõôÐ޸IJÅÐУ¿exec('insert #tab select * from student where ÐÕÃû='''+@name+'''') SQL code: exec('select * into table-name from student where ÐÕÃû='''+@name+'''')£¬
--Èç¹û±í#tab ´æÔÚ.
exec('insert #tab select * from student where ÐÕÃû='''+@name+'''' + '; select * from #tab') )
--Èç¹û±í#tab²»´æÔÚ. exec('select * into #tab from student where ÐÕÃû='''+@name+'''' + '; select * from #tab')
SQL code: declare @t table(i int) insert @t exec('select 1 a union all select 2') select * from @t /* i ----------- 1 2
(2 ÐÐÊÜÓ°Ïì) */ Ö±½Ó²å²»¾ÍÍêÁËÂð SQL code: insert #tab exec('select * from student where ÐÕÃû='''+@name+'''')