Technical Article

Change DTS package owner

,

There is a un-documented stored procedure in msdb called sp_reassign_dtspackageowner. Unfortunately, this requires a package name and will only work on one at a time.  If one developer is taking over for another, it may be helpful to change all of Bob's dts packages over to Jim.   The following procedure will do just that.

Not sure why, but M$'s procedure failed when we tried it.  It changed the owner name, but not the SID.  It appeared as if it had worked, but the new user still could not change the package. The following code worked nicely.

Create Procedure sp_reasign_dts_packages 
(
@owner varchar(255),
@newowner varchar(255), 
@package_name varchar(1000) = null
)

as


/*

--Test

declare @owner varchar(255),
@newowner varchar(255), 
@package_name varchar(1000)

set @owner = 'Bob'
set @newowner = 'Jim'
set @package_name = NULL
*/
if @package_name is null 
begin
update 
msdb.dbo.sysdtspackages 
set 
owner = @newowner, 
owner_sid = suser_sid(@newowner) 
where 
owner_sid = suser_sid(@owner)
end
else
begin
update 
msdb.dbo.sysdtspackages 
set 
owner = @newowner, 
owner_sid = suser_sid(@newowner) 
where 
owner_sid = suser_sid(@owner) and
[name] = @package_name
end

Rate

5 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (1)

You rated this post out of 5. Change rating