加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

修改SQLserver数据库的所有者(架构者名称)

发布时间:2020-12-12 14:51:42 所属栏目:MsSql教程 来源:网络整理
导读: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 tab
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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读