sql从数据库中选出千万级的表

标签: sqlserver
979人阅读 评论(0) 收藏 举报
分类:

 

 

use 数据库名
if object_id('tempdb..##') is not null drop table ##
select cast(null as sysname) as 表名称, 1 as 记录数 into ## where 1 = 0
declare @TableName sysname
declare testcur cursor for select [name] from sysobjects where xtype ='U' order by [name]
open testcur
fetch next from testcur into @TableName
while @@fetch_status = 0
begin
  exec('insert into ## select ''' + @TableName + ''', (select count(1) from ' + @TableName + ')')
  fetch next from testcur into @TableName
end
close testcur
deallocate testcur
select * from ##
 where 记录数>4000*10000


 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1689432次
    • 积分:21267
    • 等级:
    • 排名:第365名
    • 原创:577篇
    • 转载:60篇
    • 译文:0篇
    • 评论:284条
    博客专栏
    最新评论