【转】批量修改SQL Server schema

https://blog.csdn.net/wdydxf/article/details/84327556

 

declare @name sysname

declare csr cursor

for select TABLE_NAME from INFORMATION_SCHEMA.TABLES where table_schema='db_owner'

open csr

FETCH NEXT FROM csr INTO @name

while (@@FETCH_STATUS=0)

BEGIN

SET @name='db_owner.' + @name +';'

print 'ALTER SCHEMA dbo TRANSFER ' + @name

fetch next from csr into @name

END

CLOSE csr

DEALLOCATE csr

 

posted @ 2020-05-19 10:50  DuoMi  阅读(265)  评论(0)    收藏  举报