22,209
社区成员
发帖
与我相关
我的任务
分享
-- 先创建临时表 复制原始表的表结构
if object_id('tempdb..#t1') is not null
drop table #t1
select *
into #t1
from [AAA].[bbb].[dbo].[表名]
where 1=2
-- 然后在游标里
set @tsql='insert into #t1 select * from [AAA].[bbb].[dbo].[' + @tabname+ '] with (nolock) where modifydate > ''' + @lastdate + '''';
exec(@tsql)