MSSQL mirroring error 1499 - sql-server

I`ve got a problem with my mirroring. I have already uses this feature to make 2 db work.
But it was on test bases.
Now when I use my scripts on work DB it throws an error:
Msg 1499, Level 16, State 1, Line 1
Database mirroring error: status 1488, severity 16, state 1, string db_name.
Any suggestions?

you database may be in single user mode
right click the database -> options and select MULTI USER under restrict access

try to check the principal and mirror server names, dtabase name etc. It is possible that there is misprints.

This happened to us recently. We found that SQL set the restored database to single user mode during the restore process.
After some research, we simply restarted SQL server services on the mirror. When SQL started back up, the restored database was in multi-user mode and we were able to initialize mirroring without any issues.
There are other sites out there with answers as well, but they involve taking down the principle database. That was not really an option for us at the time. Here is one example in case restarting the mirror does not help the next person who runs into this.
http://blog.armgasys.com/?p=259

I had some what similar issue this is how I solved it. When I ran wizard for mirroring it created endpoints(first part) successfully but when i tried to turn on mirroring it gave me error.
So I solved it by running below command on both server
USE [master]
alter database [yourdatabase] set partner off;
go
--Secondary already had partner but primary did not
--- then i ran below commands on each server.
USE [master]
ALTER DATABASE [yourdatabase]
SET PARTNER = 'TCP://OtherMachineSQLname.domain.LOCAL:5022';
GO
-- then mirroring started to work.

Related

How can I rename an RDS SQL Server Web Edition's DB name (Not the RDS instance name, but one of the DB's inside the RDS instance)?

I have tried to rename the DB name in a RDS with SSMS but its giving below error.
User does not have permission to alter database 'DB name', the
database does not exist, or the database is not in a state that allows
access checks. (Microsoft SQL Server, Error: 5011)
Can some one please help me on this?
I have went through many articles and aws docs but did not find straight away solution so I am writing this, hope it helps someone. After some amendments to the findings, I was able to fix this issue.
Run the below queries as master on new query terminal.
use master
ALTER DATABASE YourOldDBname
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
EXEC rdsadmin.dbo.rds_modify_db_name N'YourOldDBname', N'YourNewDBname'
GO
ALTER DATABASE YourNewDBname
SET MULTI_USER
GO
If you have any active connection, you might get below error. Mostly you will not get any error as you are running above queries, if you still seeing below error please shut down any server that might be trying to establish a connection to same RDS DB.
Msg 50000, Level 16, State 2, Procedure rds_modify_db_name, Line 95 https://forums.aws.amazon.com/
The database could not be exclusively locked to perform the operation.
Hope its helped you :)

Database Keeps Going into Recovery Pending State

I have a SQL server database that has been running perfectly fine on my machine for about 6 months, a couple days ago out of nowhere it was inaccessible (Pending Recovery).
I did a bunch of Googling and have tried the following things to fix the issue but thus far restoring it from a previous backup is the only thing that seems to work.
I have tried (From SMS and SQLCMD):
ALTER DATABASE mydatabase SET EMERGENCY
ALTER DATABASE mydatabase set single_user
DBCC CHECKDB (mydatabase, REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;
ALTER DATABASE mydatabase set multi_user
Step #3 errors out with: "cannot open mydatabase is already open and can only have one user at a time"
Second try:
EXEC sp_resetstatus 'mydatabase';
ALTER DATABASE mydatabase SET EMERGENCY
DBCC CHECKDB ('mydatabase')
ALTER DATABASE mydatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CHECKDB ('mydatabase', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE mydatabase SET MULTI_USER
Step #5 errors out with the same error.
My question is what could be causing this in the first place and how can I fix it properly without having to do a restore twice a day.
Database is already open and can only have one user at a time, this is error number 924. The complete error message looks like this:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Msg 924, Level 14, State 1, Line 1 Database ‘db_name’ is already open and can only have one user at a time.
The level 14 belongs to security level errors like a permission denied. It means that it cannot be open because someone is using it.
Use the sp_who or sp_who2 stored procedures. You can also use the kill command to kill the processes that are active in the database.
I also found this thread useful: How to fix Recovery Pending State in SQL Server Database?
what could be causing this in the first place and how can I fix it properly without having to do a restore
The most likely cause is a a hardware or driver problem with your hard disk.
In my case, I had databases set up on my local machine but on an external drive mapped to my hard drive. I have the external drive connected to my docking station all the time but I had to disconnect the hard drive and after I connected it again - the databases that are restored on the external drive went into Recover Pending mode.
In my case what helped me was to set the database offline in Microsoft SQL Server Management Studio by right clicking on the database - Tasks - Take Offline. The status of the database changes to Offline. After that bring the database online again by right clicking on the database - Tasks - Bring online.
The database was successfully recovered without any issues. But if the cause is different these steps may not help.
Take the database offline
Bring the database back online

Database Recovery Pending - SQL Server 2014

My server is shutting down because the electrical. And when I opened my database in SSMS, database is recovery pending.
I checked my ERROR LOG, the message are :
4 transactions rolled forward in database 'POSDW' (14:0). This is an
informational message only. No user action is required.
restoreHkDatabase: DbId 14, Msg 41313, Level 16, State 1, The C
compiler encountered a failure. The exit code was 2.
[ERROR] Database ID: [14] 'POSDW'. Failed to load XTP checkpoint.
Error code: 0x82000009.
(d:\sql12_main_t\sql\ntdbms\hekaton\sqlhost\sqlmin\hkhostdb.cpp : 3126
- 'RecoverHkDatabase') Error: 41313, Severity: 16, State: 1.
I already tried to take offline but when I bring online I get error.
Can you guys help me.
Thanks
It looks like corruption. You can try one of the following options:
Restore from existing backup
Try enter the database into emergency mode and run DBCC CHECKDB. according to the results you can see if you can restore the pages from existing backup (in some cases) or run DBCC CHECKDB .
If you have functional replica of the data take the data from there.
Hope this helps.
You were able to move the database files while they were in "Recovery Pending" mode because that status means SQL couldn't open the database files for some reason. It also means it couldn't lock the files as well.
Setting a database to "offline" is similar because it unlocks the underlying files (that's why you can move database files while it's offline).
I'm pretty sure that if you'd try setting all these databases to "online" you'd get the error message you talk about or something similar.
ALTER DATABASE MyDB SET ONLINE
You can use the above statement to try and activate databases that are "offline" or are in "Recovery Pending" mode. If there's some kind of problem, SQL Server will let you know at that moment.
You can also read this thread: How to fix Recovery Pending State in SQL Server Database?

Cannot enable Full-Text search on Azure SQL Database V12

I'm trying to enable Full-Text search on my Azure SQL Database. I upgraded my DB to V12 Standard instance. The upgrade has got completed successfully. I say that because the Status says "Online" on the portal. However, when I execute this command below,
CREATE FULLTEXT CATALOG ftCatalog AS DEFAULT;
it throws an error saying,
Msg 9972, Level 16, State 100, Line 2
Database is not fully started up or it is not in an ONLINE state. Try the full-text DDL command again after database is started up and becomes ONLINE.
I am following this blog post
What could be wrong?
Executing the below two statements by connecting to the database as well fixes this if in case you want to avoid the round trip of communicating to MSFT.
Alter database [dbname] set read_committed_snapshot off with rollback immediate
Alter database [dbname] set read_committed_snapshot on with rollback immediate
Thank you for the question. The error you are experiencing is related to an internal issue that we are aware of and currently in the process of fixing. To mitigate your issue, could you please email me at joseidz at microsoft dot com with server and database name and we will get this fixed for you.

SQL Server production server - all databases are in recovery pending state

All the databases in my SQL Server production server are in recovery pending state. I tried to execute different queries but they were of no use. Please help me as production work has been stopped at client side.
Tried to execute alter commands - but show error as following:
Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file
"G:\Data\MSSQL\Database.mdf". Operating system error 3: "3(The system
cannot find the path specified.)". File activation failure. The
physical file name "G:\Data\MSSQL\Data\Database_log.ldf" may be
incorrect. Msg 945, Level 14, State 2, Line 1 Database 'Database'
cannot be opened due to inaccessible files or insufficient memory or
disk space. See the SQL Server errorlog for details
Msg 5069, Level 16, State 1, Line 1
Recovery pending means that for some reason SQL cannot run restart recovery on the database. Usually this is because the log is missing or corrupt.
Check to see if you can find the Database.mdf and Database_log.ldf files in the folder specified.
Check your system has not run out of disk space.
This could be caused by a hard drive failure. You may need to do a full restore of your last full back, any differentials and then restore the logs up until the log error occurred.
See similar issue here
My team encountered this error many times for my clients & I know, It is not easy to manage in the Production server. In your case Error 5120 –This error comes when the database is in Read Only Mode.
To fix this you can below code
USE [master]
GO
ALTER DATABASE [SQLAuthority] SET READ_WRITE WITH NO_WAIT
GO
After fixing 5120, you can process to fix "databases are in recovery pending state"
Recovery Pending – If the SQL Server knows that database recovery needs to be run but something is preventing it from starting, the Server marks the db in ‘Recovery Pending’ state. This is different from the SUSPECT state because it cannot be said that recovery is going to fail – it just hasn’t started yet.
Execute the following set of queries:
ALTER DATABASE [DBName] SET EMERGENCY; GO
ALTER DATABASE [DBName] set single_user GO
DBCC CHECKDB ([DBName], REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS; GO
ALTER DATABASE [DBName] set multi_user GO
Note: You can also read the Microsoft Warning on DBCC CHECKDB REPAIR ALLOW DATA LOSS.
It might be because of following possible causes:
Permissions
Find your SQL Server instance in the services list and double-click it, then select the Log On tab. It is this log on account that must have sufficient permissions to write to the temporary backup folder location. Check the permissions on the temporary backup folder by right-clicking it in Windows Explorer, selecting Properties, then navigating to the Security tab. Make sure that the account SQL Server is using has explicit read/write permissions for this folder.
Mapped Drives
Use a fully qualified UNC path instead of a mapped drive letter.
Lack Of Domain Trust
You can resolve this issue by ensuring that a trust between the two domains is established. You may also need to configure the SQL Server service account with pass-through authentication between the domains.
Please refer more here for recovery db
Execute these queries to fix SQL server database in recovery pending state:
ALTER DATABASE [DBName] SET EMERGENCY
GO
ALTER DATABASE [DBName] SET single_user
GO
DBCC CHECKDB ([DBName], REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS
GO
ALTER DATABASE [DBName] SET multi_user
GO
EMERGENCY mode marks the SQL Server database as READ_ONLY, deactivates logging, and gives the permission to system admin only. This method is capable of resolving any technical issue and bringing the database back to the accessible state. The database will automatically come out of the EMERGENCY mode.

Resources