sys.fn_hadr_backup_is_preferred_replica returns 1 of database does not exists - by Robert Hartskeerl

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 712548 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 12/8/2011 9:59:07 AM
Access Restriction Public


The function sys.fn_hadr_backup_is_preferred_replica returns 1 of a databasename is not supplied (null) or if a non-existing databasename is supplied. This will not raise an error which may cause the user to be misled.
Sign in to post a comment.
Posted by Microsoft on 12/13/2011 at 3:20 PM
fn_hadr_backup_is_preferred_replica is designed to return TRUE if the local replica is the preferred replica according to user configuration, when the database is part of an AG.
It will also return TRUE for a Database Mirroring database when run on the Primary, and FALSE when run on a DBM secondary.

If the database is not part of an AlwaysOn Availability Group or a Database Mirroring environment, the function should cause the job to behave exactly as if AlwaysOn were not in the picture.
So, it will always return TRUE if the input database is not part of an AG or a DBM configuration.

In this case, a non-existent database is definitely not part of any AG or DBM environment, so we allow the backup statement to proceed, which will return the same error it always would.