你的位置: Kiyo'Space首页 数据库 阅读文章 欢迎留下您的足迹

批量修改sqlserver 2005 架构为dbo

[ 数据库 ] 分享

修改表架构命令为:

Alter SCHEMA dbo TRANSFER  tName

 

于是:

declare @name varchar(100),@sql nvarchar(255)
declare csr1 cursor
 for
 select ‘Name’ = name
 from sysobjects
 where user_name(uid)=xxxx–注意红色部分需要修改
 order by name
 open csr1
 FETCH NEXT FROM csr1 INTO @name
 while (@@FETCH_STATUS=0)
 BEGIN
 SET @name=’xxxx.’+@name
 EXEC SP_ChangeObjectOwner @name, ‘dbo’
 fetch next from csr1 into @name
 END
 CLOSE csr1

 DEALLOCATE csr1

没有评论

  • (Required)
  • (Required, will not be published)