- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我继承了一个 SQL 2008 数据库,其中它的所有对象都以作为所有者的开发人员名称为前缀,即 ownername.sp_get_all_users。
我已将数据库恢复到 SQL Server 2016 Express Edition。
有数百个 dbase 对象,有没有办法自动将对象所有者更改为 dbo 而不是手动编辑每个对象?
我尝试了以下方法,但显然自 SQL Server 2005 以来您不能再对对象进行临时更改?
SELECT * from sysobjects where uid = user_id('UseNAme')
declare @Return int
exec @Return = sp_configure 'allow updates', '1'
SELECT @Return as 'Returned Code'
GO
reconfigure WITH OVERRIDE
GO
DECLARE @Rows int, @Error int
BEGIN TRANSACTION
update sysobjects set uid = user_id('dbo') where uid = user_id('UseNAme')
SELECT @Error = @@Error, @Rows = @@RowCount
SELECT @Rows as '#Rows'
IF @Rows > 0
BEGIN
SELECT @Rows AS '#Rows'
COMMIT TRANSACTION
END
else
BEGIN
SELECT @Error AS 'Error #'
ROLLBACK TRANSACTION
END
exec sp_configure 'allow updates', '0'
reconfigure WITH OVERRIDE
go
非常感谢任何帮助。
最佳答案
您必须使用 Alter Schema...
ALTER SCHEMA oldschemaname TRANSFER dbo.Address;
下面要自动化使用
this will change all tables which have a schema other than system to dbo,note if you have two tables in different schema,they can't exist in same schema
select *,row_number() over (order by (select null)) as rownum
into #tables
from information_Schema.tables
where table_schema in (select name from sys.schemas
where name not in ('dbo','guest','INFORMATION_SCHEMA','sys') and principal_id <16384
)
now move
declare @min int,@max int
select @min=min(rownum),@max=max(rownum)
from #tables
declare @tblname varchar(255),@schemaname sysname
declare @sql varchar(max)
while @min<=@max
Begin
select @tblname=table_name,@schemaname=table_schema from
#tables where rownum=@min
set @sql='alter schema dbo transfer '+ @schemaname+'.'+@tblname
--print @sql
exec(@sql)
Set @min=@min+1
End
sp_change object owner as per documentation states..
This stored procedure only works with the objects available in MicrosoftSQL Server 2000. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER SCHEMA or ALTER AUTHORIZATION instead. sp_changeobjectowner changes both the schema and the owner. To preserve compatibility with earlier versions of SQL Server, this stored procedure will only change object owners when both the current owner and the new owner own schemas that have the same name as their database user names.
关于sql-server - SQL Server 2016 更改对象所有者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40680280/
假设我有一个简单的模型: class Contact(models.Model): owner = models.ForeignKey(User, editable=False) fi
我在docker容器中的轨道上运行ruby。如果生成类似docker-compose run rails rails g controller posts index show的文件,则文件所有者为r
这个问题在这里已经有了答案: Get Component's Parent Form (10 个答案) 关闭 3 年前。 如何从嵌入到表单中的自定义 Winforms 组件获取父/所有者控件? 我有
我这里有密码 @interface FFRightSidebarController () @property (nonatomic, strong) FFActivitiesController *
假设您有这些表:RestaurantChains、Restaurants、MenuItems - 它们之间存在明显的关系。现在,您有表 Comments 和 Ratings,它们存储客户对链式店、餐馆
我有以下 View 层次结构, ... ... .... 单个订单的更新通过推送器进行。 我是 React 新手,想知道以下哪一个是更
所以我有一个位于另一个用户控件内部的用户控件。我们称它们为 ParentUC 和 ChildUC。我需要从 ChildUC 获取 ParentUC。 我知道获取窗口所有者的方法是Window.GetW
我们创建了 Telegram Bot ,它有许多困难的操作。机器人是由一位开发人员使用他的电话号码创建的。是否可以更改机器人的所有者或添加其他用户作为机器人的管理员? 最佳答案 最近出现了将机器人转给
默认情况下,对象(表、存储过程等)是使用 dbo 所有者/架构设置的(我认为 ms sql 2000 称其为所有者,而 ms sql 2005 称其为架构) 所有者/架构实际上是数据库中的角色或用户。
在 Mortar 中,如果 ActionBar 根据显示的屏幕发生变化,我很好奇人们如何处理它。例如,假设您想要在显示特定屏幕时更改 ActionBar 标题或操作。 注入(inject) Activ
我正在使用 Stripe.js 和 Stripe Elements 开发购物车结帐页面,而不是使用 Stripe 的结帐小部件。 在结帐页面上,使用了所有 4 个可用元素(卡片、邮政编码、expire
我尝试将本地仓库推送到 github 并收到这样的消息: The remote end hung up unexpectedly. ERROR: Permission to [repo_name] d
我是 WHM、cPanel 和 CentOS 的新手。 我安装 WHM 然后为域创建一个帐户 app.example.com和用户 peter我将域名指向正确的 IP 地址,但是当我运行我的网站 ap
我已经在 GitHub 上提交了一个项目的问题,该项目不是我的,我也不是贡献者,但我找不到标记我的问题的方法。有没有办法让我给它贴上标签,或者这只适用于贡献者? 最佳答案 它仅适用于贡献者。 这样,您
我到处都找过了,但一直找不到我要找的东西。我知道我需要什么,但无法将 2 和 2 放在一起。 我需要允许用户创建群组并允许其他用户加入群组。 任何用户都可以创建群组。 任何用户都可以发送加入另一个群组
我到处都找过了,但一直找不到我要找的东西。我知道我需要什么,但无法将 2 和 2 放在一起。 我需要允许用户创建群组并允许其他用户加入群组。 任何用户都可以创建群组。 任何用户都可以发送加入另一个群组
这是我的代码: class SpecialMeanings{ String prop1 = "prop1" def closure = { String prop1 = "inner_
我一直在使用 java OWNER 进行基于属性的配置。 我创建了一个静态方法 public static final ApplicationConfiguration config = Config
我正在运行 OpenSSH sftp-server(Linux、Raspbian),FileZilla 用作客户端。我遇到的问题是用户可以删除服务器上的任何文件,而不管文件掩码或所有者/组: 登录的用
这是一个简单的问题,我无法通过谷歌搜索和查看 github documents 找到答案。 . 如果有人对 github 中已关闭的问题发表新评论,是否会通知 Repo 所有者? 最佳答案 如果向已关
我是一名优秀的程序员,十分优秀!