惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
D
Docker
J
Java Code Geeks
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
The GitHub Blog
The GitHub Blog
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
腾讯CDC
罗磊的独立博客
U
Unit 42
爱范儿
爱范儿
Vercel News
Vercel News
MyScale Blog
MyScale Blog

博客园 - 吴尔平

gtest 的彩色信息输出 + boost.test 的内存泄漏检测及定位 在低版本的 vc 中使用 vc 10.0 的新特性 使用另一个blog: http://blog.csdn.net/WuErPing scons + swig 如何在 vista 使用 Device Emulator 连接internet vc9 Feature Pack Beta tr1 的一些问题 NSIS Kill Process (转贴) C#与一个彩票页面 - 吴尔平 - 博客园 py2exe 转换 pytetris - 吴尔平 关于模板化的friend class C# 的 random shuffle python 读取 windows event log 的简短代码 IronPython 1.0 Release Candidate (转贴 ( 据说比c实现的快1.5!) ) Visual Studio Service Pack (转贴) The 16th Annual Jolt Product Excellence Award Winners (转贴) C++/CLI FAQ (逐步整理中) C++/CLI singleton模式 (双重检测锁实现) 如何在 VS2005 的 Team Unit Testing frameworks 中测试 Native Code (C++ ) 2005 CRT memory leaks
改变 SQL Server 2000 所有对象的所有者
吴尔平 · 2005-12-19 · via 博客园 - 吴尔平

    俺只测试了表和存储过程,其它对象未有实际测试,使用前请备份数据库任何错误俺概不负责 ^_^

 1 /*
 2  brief:    改变数据库所有对象的所有者
 3  author: 吴尔平
 4  date:    2005/12/19
 5 */
 6 
 7 declare @owner varchar(255)
 8 set @owner = 'dbo'
 9 
10 declare @objectname varchar(255)
11 declare @uid int
12 declare object_cursor cursor for select [name],uid from sysobjects 
13 where  OBJECTPROPERTY (id, 'IsMSShipped'= 0 
14 and (xtype like  '%'--  如果要指定对象的类型,参考 Transact-SQL 帮助-> sysobjects-> xtype
15 open object_cursor
16 fetch next from object_cursor into @objectname@uid
17 while(@@fetch_status=0)
18 begin
19     declare @uidName varchar(255)
20     select @uidName = [name] from dbo.sysusers where uid = @uid
21     if @uidName <> @owner
22         begin
23             --生成 '所有者.对象名' 格式的字符串
24             set @objectname = @uidName + '.' + @objectname
25             --改变对象所有者
26             exec sp_changeobjectowner @objectname@owner
27         end
28 
29     fetch next from object_cursor into @objectname@uid
30 end
31 close object_cursor
32 deallocate object_cursor
33 go