--更新資料庫中所有表的所有者
exec
sp_msforeachtable 'sp_changeobjectowner ''?'',''dbo'''
--更新資料庫中所有物件的所有者
create
procedure dbo.changeobjectowner
@oldowner as
nvarchar(128),--引數原所有者
@newowner as
nvarchar(128)--引數新所有者
asdeclare @name as
nvarchar(128)
declare @owner as
nvarchar(128)
declare @ownername as
nvarchar(128)
declare curobject cursor
forselect 'name' = name,
'owner' = user_name(uid)
from sysobjects
where user_name(uid)=@oldowner
order
by name
open curobject
fetch
next
from curobject into @name, @owner
while(@@fetch_status=0)
begin
if @owner=@oldowner
begin
set @ownername = @oldowner + '.' + rtrim(@name)
exec
sp_changeobjectowner @ownername, @newowner
endfetch
next
from curobject into @name, @owner
endclose curobject
deallocate curobject
go--更新資料庫中儲存過程的所有者
create
procedure changeprocowner
@oldowner as
nvarchar(128),--引數原所有者
@newowner as
nvarchar(128)--引數新所有者
asdeclare @name as
nvarchar(128)
declare @owner as
nvarchar(128)
declare @ownername as
nvarchar(128)
declare curobject cursor
forselect 'name' = name,
'owner' = user_name(uid)
from sysobjects
where user_name(uid)=@oldowner and xtype='p'
order
by name
open curobject
fetch
next
from curobject into @name, @owner
while(@@fetch_status=0)
begin
if @owner=@oldowner
begin
set @ownername = @oldowner + '.' + rtrim(@name)
exec
sp_changeobjectowner @ownername, @newowner
endfetch
next
from curobject into @name, @owner
endclose curobject
deallocate curobject
go--exec changeprocowner 'user','dbo'
資料庫 事務,儲存過程 (更新)
是作為單個邏輯單元執行的一系列操作,這些操作作為乙個整體一起向系統提交,要麼都執行,要麼都不執行。事務是乙個不可分割的工作邏輯單元 事務必須具備以下四個屬性,簡稱acid屬性 原子性 atomicity 一致性 consistency 隔離性 isolation 永久性 durability 一組為...
編寫儲存過程將資料庫中表中資料轉換sql指令碼語言
一 儲存過程 use database 資料庫名稱database goset ansi nulls off goset quoted identifier off gocreate procedure dbo uspoutputdata tablename sysname asdeclare co...
資料庫 儲存過程
儲存過程,stored procedure,是在大型資料庫系統中,一組為了完成特定功能的sql語句集,經編譯後儲存在資料庫中,使用者通過指定儲存過程的名字並給出引數 如果該儲存過程帶有引數 來執行它。模擬於c中的函式。mysql與sqlserver是不同的。建立儲存過程 conn getconnec...