用脚本批量导数据_游标

----------------------
declare @index int set @index=0
declare @table varchar(100)
declare cu cursor for
select name from sys.objects where type='u'  order by name
open cu
fetch next from cu into @table
while @@fetch_status=0
begin
    exec(' truncate table '+@table+'
    insert into '+@table+'
    select * from vsat_jj_data.dbo.'+@table+'
')
set @index=@index+1
print @table
print @index
fetch next from cu into @table
end
close cu
deallocate cu
--------

您可以选择一种方式赞助本站