declare @table_name varchar(50) ,@schema_id int ,@schema_name varchar(50) ,@sql_cmd nvarchar(255) declare table_cursor cursor for select name,schema_id from sys.tables where schema_id <> 1 -- dbo 的 schema_id = 1 order by name open table_cursor fetch next from table_cursor into @table_name,@schema_id while @@fetch_status = 0 begin print '' select @schema_name = name from sys.schemas where schema_id = @schema_id select @sql_cmd = 'alter schema dbo transfer ' + @schema_name + '.' + @table_name print @sql_cmd exec sp_executesql @sql_cmd fetch next from table_cursor into @table_name,@schema_id end close table_cursor deallocate table_cursor go
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。