[SQL Server2000] How to modify the object belonging.

xiaoxiao2021-03-06  95

Create Procedure DBo.changeObjectowner @OLDOWNER As NVARCHAR (128), @newowner as nvarchar (128) AS

Declare @name as nvarchar (128) Declare @owner as nvarchar (128) Declare @Ownername as nvarchar (128)

DECLE CUROBJECT CURSOR for SELECT NAME = Name, Owner = user_name (uid) from sysobjects where user_name (uid) = @ Oldowner ORDER BY NAME

OPEN curObjectFETCH NEXT FROM curObject INTO @Name, @OwnerWHILE (@@ FETCH_STATUS = 0) BEGIN if @ Owner = @ OldOwner begin set @OwnerName = @OldOwner '.' Rtrim (@Name) exec sp_changeobjectowner @OwnerName, @NewOwner end

Fetch next from curobject @Name, @Ownerend

Close Curobjectdeallocate CurobjectGO

Exec ChangeObjectowner Ro, DBO

转载请注明原文地址:https://www.9cbs.com/read-122135.html

New Post(0)