-- Renaming Databases
sp_who2
-- Optional but should be done for MyDB-DEV-NEW
EXEC Utility.dbo.BACKUP_APP_INTERFACE_PARAMETER_TBL_sp
GO
-- kill 88
SP_WHO2
-- Optional but should be done for MyDB-DEV-NEW
ALTER DATABASE [MyDB-TMAR] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE [MyDB-TMAR-NEW] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
USE master;
GO
ALTER DATABASE [MyDB-TMAR]
Modify Name = [MyDB-TMAR_OLD];
GO
ALTER DATABASE [MyDB-TMAR-NEW]
Modify Name = [MyDB-TMAR];
GO
EXEC Utility.dbo.RESTORE_APP_INTERFACE_PARAMETER_TBL_sp 'MyDB-TMAR'
GO
-- ALTER DATABASE [MyDB-TMAR] SET MULTI_USER WITH ROLLBACK IMMEDIATE;
-- ALTER DATABASE [MyDB-TMAR_OLD] SET MULTI_USER WITH ROLLBACK IMMEDIATE;
--use utility
--go
--select * from sysobjects where type = 'p'
-- EXEC Utility.dbo.TMARDBRestore_RemoveTRSJobs 'MyJob'
EXEC Utility.dbo.TMARDBRestore_RemoveTRSJobs 'MyJob'
GO
USE [MyDB-TMAR]
GO
DROP FULLTEXT INDEX ON MyDB_product_search
GO
--DROP FULLTEXT CATALOG MyDB_product_search
--GO
ALTER DATABASE [MyDB-TMAR] SET MULTI_USER;
GO
ALTER DATABASE [MyDB-TMAR_OLD] SET MULTI_USER;
GO
USE [MyDB-TMAR]
GO
IF EXISTS (
SELECT *
FROM sys.database_principals
WHERE name = 'MyDB-'
)
DROP USER [MyDB-]
CREATE USER [MyDB-] FOR LOGIN [MyDB-]
-- ALTER ROLE [db_owner] ADD MEMBER [MyDB-]
EXEC sp_addrolemember N'db_owner', N'MyDB-'
-- NOTE: remember to add in user "Myweb" to prod1 and prod2
USE [MyDB-TMAR]
GO
IF EXISTS (
SELECT *
FROM sys.database_principals
WHERE name = 'Myweb'
)
DROP USER [Myweb]
CREATE USER [Myweb] FOR LOGIN [Myweb]
-- ALTER ROLE [db_owner] ADD MEMBER [MyDB-]
EXEC sp_addrolemember N'db_owner', N'Myweb'
GO
-- NOTE: remember to add in user "MyAdmin" to prod1 and prod2
USE [MyDB-TMAR]
GO
IF EXISTS (
SELECT *
FROM sys.database_principals
WHERE name = 'MyAdmin'
)
DROP USER [MyAdmin]
CREATE USER [MyAdmin] FOR LOGIN [MyAdmin]
-- ALTER ROLE [db_owner] ADD MEMBER [MyDB-]
EXEC sp_addrolemember N'db_owner', N'MyAdmin'