1. Changing object Ownership
EXEC sp_changeobjectowner 'CurrentOwner.ObjectName, 'NewOwner';
eg
EXEC sp_changeobjectowner 'IAM\vnaraya.RPT_HLD_PROF, 'DBO';
***********************************************
2.Steps to rename a Database
sp_renameDB
detach DB
rename mdf ldf
attach DB
script is following
--renaming database
use master
sp_dboption 'OLDDBNAME', 'single user', 'TRUE'
go
sp_renamedb 'OLDDBNAME', 'NEWDBNAME'
go
--Detaching database
EXEC sp_detach_db 'NEWDBNAME', 'true';
go
--Rename MDF and LDF file manually
--Attach Database
EXEC sp_attach_db @dbname = N'NEWDBNAME',
@filename1 = N'E:\Program Files\Microsoft SQL Server\MSSQL\Data\NEWDBNAME_Data.MDF',
@filename2 = N'F:\Program Files\Microsoft SQL Server\MSSQL\log\NEWDBNAME_Log.LDF'
--Take full backup of new database
use dba_perform
sp_dba_backup_full 'NEWDBNAME'
sp_dboption 'NEWDBNAME', 'single user', 'False'
go
******************************************
Monday, May 7, 2007
Subscribe to:
Posts (Atom)