📄 61724.htm
字号:
<link href="./dzs_cs.css" rel="stylesheet" type="text/css" /><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> <tr> <td height="24" align="center" valign="bottom" class="d_font3">SQL Server中修改对象所有者的两种方法</td> </tr> <tr> <td height="3" bgcolor="#E3E3E3"></td> </tr> <tr> <td> </td> </tr> <tr> <td class="d_font4"><P>一般开发,SQL Server的数据库所有者为dbo。但是,为了安全,有时候可能把它换成其它的名称。所有者变换不是很方便,这里列出两种供参考。</P>
<P><STRONG>方案一:更改权限以添加HHRC用户</STRONG></P>
<P>1、添加第三方用户,如“chn”;<BR>2、运行sql,加对象权限移至第三方用户;<BR>3、添加hhrc用户;<BR>4、运行sql,将对象权限移至hhrc用户。</P>
<P>
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>declare @tblname varchar(30)<BR>declare @tblown varchar(50)<BR>declare tbl_cur cursor for <BR>select name from sysobjects where uid='5' and status>=0 and xtype in ('U','P')<BR>--select * from sysusers<BR>open tbl_cur<BR>fetch next from tbl_cur into @tblname<BR>while @@fetch_status=0<BR>begin<BR>set @tblown='web56433.'+@tblname<BR>EXEC sp_changeobjectowner @tblown, 'chn'<BR>print @tblname<BR>fetch next from tbl_cur into @tblname<BR>end<BR>close tbl_cur<BR>deallocate tbl_cur</PRE></TD></TR></TBODY></TABLE></P>
<P><STRONG>方案二:</STRONG></P>
<P>1、手动修改系统表;<BR>2、设备可以手动修改表;</P>
<P>
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>exec sp_configure 'allow updates',1<BR>RECONFIGURE WITH OVERRIDE</PRE></TD></TR></TBODY></TABLE></P>
<P>3、更改对象所有者。</P>
<P>
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE><P>update sysobjects set uid = 1 where uid = 5<BR>update sysobjects set uid = 5 where uid = 1 AND xtype != 'S'<BR>update sysobjects set uid = 1 where name = 'syssegments'<BR>update sysobjects set uid = 1 where name = 'sysconstraints'<BR>exec sp_configure 'allow updates',0<BR>RECONFIGURE WITH OVERRIDE</P></PRE></TD></TR></TBODY></TABLE></P>
<P><FONT size=4>【相关文章】</FONT></P>
<UL type=disc>
<LI><A href="http://database.51cto.com/art/200704/44253.htm" target=_blank><U><FONT color=blue>理解SQL Server的SQL查询计划</FONT></U></A></LI></UL>
<UL type=disc>
<LI><A href="http://database.51cto.com/art/200703/42242.htm" target=_blank><U><FONT color=blue>利用索引提高SQL Server数据处理效率</FONT></U></A></LI></UL>
<UL type=disc>
<LI><A href="http://database.51cto.com/art/200701/39262.htm" target=_blank><U><FONT color=blue>利用SQL Server数据库快照形成报表</FONT></U></A></LI></UL><DIV align=right>【责任编辑:<A class=ln href='mailto:sunsj@51cto.com'>火凤凰</A> TEL:(010)68476606】</DIV></td> </tr> <tr> <td class="d_font4"> </td> </tr> </table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -