sql 拆分为小表

alter table [Table] add id int identity(1,1)
go
declare @i int
declare @sql varchar(1000)
set @i=0
while @i<=39
begin
     set @sql='select * into [TB'+ltrim(i)+'] from [Table] where id between @i*50000+1 and (@i+1)*50000'
     exec(@sql)  
     set @i=@i+1   
end
原文地址:https://www.cnblogs.com/forthelichking/p/4836051.html