select@sql1=substring(@sql1,2,8000)
exec(insertinto+@n_dbname+..[+@tbname+](+@sql1
+)select+@sql1+from+@o_dbname+..[+@tbname+])
if@@error0
print(insertinto+@n_dbname+..[+@tbname+](+@sql1
+)select+@sql1+from+@o_dbname+..[+@tbname+])
fetchnextfrom#tbinto@tbname
end
close#tb
deallocate#tb
--数据复制完成后启用束缚
open#tbc
fetchnextfrom#tbcinto@name,@tbname
while@@fetch_status=0
begin
set@sql=altertable+@n_dbname+..[+@tbname+]CHECKCONSTRAINT[+@name+]
exec(@sql)
fetchnextfrom#tbcinto@name,@tbname
end
close#tbc
deallocate#tbc
go