Technical Article

How to Change all Table owner one in to another in sql server 2000?

,

If you need to delete one user and add the entire related table that user to another user you can easily use this method.

  • Run example 1 Sql statements to set updatable mode to system database(master)
  • Before change,
  • Then run example 2 Sql statements to change owner of the tables
  • After change,
--===========
--example 1 
--===========
use master
go
--to set system table update configure
sp_configure 'allow updates', 1
GO
RECONFIGURE WITH OVERRIDE
GO


--===========
--example 2 
--===========
use master
go
--to get user id
DECLARE @intNewUid int
DECLARE @intOldUid int
SELECT @intNewUid=uid FROM pubs.dbo.sysusers WHERE (name='Tharindu');--new user
SELECT @intOldUid=uid FROM pubs.dbo.sysusers WHERE (name='dbo');--old user
--Update values
UPDATE pubs.dbo.sysobjects SET uid=@intNewUid WHERE (type='U') and (uid=@intOldUid);
go

Rate

3 (2)

You rated this post out of 5. Change rating

Share

Share

Rate

3 (2)

You rated this post out of 5. Change rating