Labels
- Differences (38)
- MongoDB (13)
- MySQL (10)
- Oracle (6)
- ORACLE DBA (1)
- Performance Tuning (13)
- PTuning (3)
- Scenarios (4)
- Scripts (35)
- SQLDBA (99)
- SQLDeveloper (66)
- SSIS (5)
- SSRS (8)
- Troubleshooting (37)
Tuesday, 14 March 2017
How to restore database in AG
ü
Backup the exisitng dataabse
|
ü
Take the security backup
|
ü Remove the databases from availability group : AlwaysOn High
Availability --> Availability Groups
è
Group Name Ex:AG_Test
-->Availability Databases --> DatabaseName
--> Remove Database
Name from Availability Group
|
ü
Restore the databases
|
ü
Execute the security
permissions ( which you have taken before restore) on newly restored
database.
|
ü
Remove the availability
databases on secondary
|
ü
Add the databases to the
Availability group
|
Can We delete the database pariticipating in AG ?
You cannot delete the database which participating in AG . If you try to delete the database then you will get the error like -
The operation cannot be performed on database "DB Name" because it is involved in a database mirroring session or an availability group
For more details about errors
TITLE: Microsoft SQL Server Management Studio
------------------------------
Alter failed for Database 'DBNAME'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=12.0.5000.0+((SQL14_PCU_main).160617-1804)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Alter+Database&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
The operation cannot be performed on database "DB Name" because it is involved in a database mirroring session or an availability group. Some operations are not allowed on a database that is participating in a database mirroring session or in an availability group.
ALTER DATABASE statement failed. (Microsoft SQL Server, Error: 1468)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=12.00.5000&EvtSrc=MSSQLServer&EvtID=1468&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
The operation cannot be performed on database "DB Name" because it is involved in a database mirroring session or an availability group
For more details about errors
TITLE: Microsoft SQL Server Management Studio
------------------------------
Alter failed for Database 'DBNAME'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=12.0.5000.0+((SQL14_PCU_main).160617-1804)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Alter+Database&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
The operation cannot be performed on database "DB Name" because it is involved in a database mirroring session or an availability group. Some operations are not allowed on a database that is participating in a database mirroring session or in an availability group.
ALTER DATABASE statement failed. (Microsoft SQL Server, Error: 1468)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=12.00.5000&EvtSrc=MSSQLServer&EvtID=1468&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
Can we restore database pariticipating in AG Group .
you cannot restore the database directly participating on AG. Please refer the below error for more details.
Msg 3104, Level 16, State 1, Line 2 RESTORE cannot operate on database 'DBNAME 'because it is configured for database mirroring or has joined an availability group. If you intend to restore the database, use ALTER DATABASE to remove mirroring or to remove the database from its availability group. Msg 3013, Level 16, State 1, Line 2 RESTORE DATABASE is terminating abnormally. | |
In order to proceed with restore, first you need to remove the database from the AG and restore the db.Make sure you took database level permissions before restore and apply the permissions after restore. |
Thursday, 2 March 2017
Script to find when backup started and finished in SQL Server
In order to get the backup start date and backup end date we need to use backupfile,backupmediafamily and backupset tables with dbo schema available in msdb system database .
SELECT CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS SERVER ,msdb.dbo.backupset.database_name ,msdb.dbo.backupset.backup_start_date ,msdb.dbo.backupset.backup_finish_date ,msdb.dbo.backupset.expiration_date ,CASE msdb..backupset.typeWHEN 'D' THEN 'Database' WHEN 'L' THEN 'Log' END AS backup_type ,msdb.dbo.backupset.backup_size ,msdb.dbo.backupmediafamily.logical_device_name ,msdb.dbo.backupmediafamily.physical_device_name ,msdb.dbo.backupset.NAME AS backupset_name ,msdb.dbo.backupset.descriptionFROM msdb.dbo.backupmediafamily INNER JOIN msdb.dbo.backupset ONORDER BY msdb.dbo.backupset.database_name ,msdb.dbo.backupset.backup_finish_date
Subscribe to:
Posts (Atom)