{"id":4475,"date":"2015-03-30T19:11:17","date_gmt":"2015-03-30T17:11:17","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/"},"modified":"2015-03-30T19:11:17","modified_gmt":"2015-03-30T17:11:17","slug":"weird-issue-with-sysfnhadrbackupispreferredreplica-function","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/","title":{"rendered":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function"},"content":{"rendered":"<p>A couple of days ago, I faced a weird backup issue with SQL Server AlwaysOn and availability groups at one of my customer (thank to him to point out this issue \ud83d\ude42 ). After installing our <a href=\"index.php\/products\/database-management-kit\">DMK<\/a> tool (Database Management Kit) about database maintenance for AlwaysOn, my customer noticed that their databases have not backed up. Ouch \u2026 what\u2019s going on? I never ran into this issue before&#8230; Do the problem comes from our tool?<\/p>\n<p>In fact, our DMK uses the useful DMF <em>sys.fn_hadr_backup_is_preferred_replica()<\/em> to know which databases are candidate for backup operations on replicas at a given time and this is where our issue starts. Indeed, in a specific situation that includes both a case sensitive server collation and entering the name of replicas in lower case, we found that the result of this function is inconsistent. Let me show with an example.<\/p>\n<p>In my customer\u2019s context, the replica names have been filled out from a PowerShell script form in lower case as follows:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_powershell_script.jpg\" alt=\"blog_37_-_powershell_script\" width=\"437\" height=\"186\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Let\u2019s take a look at the system view to check the availability group configuration:<\/p>\n<p>&nbsp;<\/p>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">SELECT<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 replica_server_name<span style=\"color: gray\">,<\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 availability_mode_desc<span style=\"color: gray\">,<\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 failover_mode_desc<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">FROM<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: green\">sys<span style=\"color: gray\">.availability_replicas<\/span><\/span><\/span><\/span><\/div>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_availability_replicas_name.jpg\" alt=\"blog_37_-_availability_replicas_name\" width=\"300\" height=\"63\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Let\u2019s verify that the collation of the SQL Server instance is case sensitive \u2026<\/p>\n<p>&nbsp;<\/p>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">SELECT<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: fuchsia\">SERVERPROPERTY<span style=\"color: gray\">(<span style=\"color: red\">&#8216;Collation&#8217;<span style=\"color: gray\">) <span style=\"color: blue\">AS ServerCollation<span style=\"color: gray\">;<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_server_collation.jpg\" alt=\"blog_37_-_server_collation\" width=\"121\" height=\"47\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u2026 and the backup preference policy is configured to \u201cprimary\u201d<\/p>\n<p>&nbsp;<\/p>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">SELECT<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 name <span style=\"color: blue\">AS group_name<span style=\"color: gray\">,<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 automated_backup_preference_desc <span style=\"color: blue\">as backup_preference<\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">FROM<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: green\">sys<span style=\"color: gray\">.availability_groups<\/span><\/span><\/span><\/span><\/div>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_backup_preference.jpg\" alt=\"blog_37_-_backup_preference\" width=\"173\" height=\"43\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Finally, let\u2019s verify the database inside the availability group:<\/p>\n<p>&nbsp;<\/p>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">SELECT<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g<span style=\"color: gray\">.name <span style=\"color: blue\">AS group_name<span style=\"color: gray\">, <\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 r<span style=\"color: gray\">.replica_server_name <span style=\"color: blue\">AS replica_name<span style=\"color: gray\">,<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 dcs<span style=\"color: gray\">.database_name<span style=\"color: gray\">,<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 drs<span style=\"color: gray\">.database_.state_desc <span style=\"color: blue\">AS db_state<\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">FROM<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: green\">sys<span style=\"color: gray\">.dm_hadr_database_replica_states <span style=\"color: blue\">AS drs<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">JOIN<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: green\">sys<span style=\"color: gray\">.availability_replicas <span style=\"color: blue\">AS r<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">ON drs<span style=\"color: gray\">.replica_id <span style=\"color: gray\">= r<span style=\"color: gray\">.replica_id<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">JOIN<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: green\">sys<span style=\"color: gray\">.availability_groups <span style=\"color: blue\">AS g<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">ON g<span style=\"color: gray\">.group_id <span style=\"color: gray\">= drs<span style=\"color: gray\">.group_id<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: gray\">JOIN<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: green\">sys<span style=\"color: gray\">.dm_hadr_database_replica_cluster_states <span style=\"color: blue\">AS dcs<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue\">ON dcs<span style=\"color: gray\">.group_database_id <span style=\"color: gray\">= drs<span style=\"color: gray\">.group_database_id<\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: gray\">AND dcs<span style=\"color: gray\">.replica_id <span style=\"color: gray\">= drs<span style=\"color: gray\">.replica_id<\/span><\/span><\/span><\/span><\/span><\/div>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_dummy_database.jpg\" alt=\"blog_37_-_dummy_database\" width=\"279\" height=\"48\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Ok now let\u2019s take a look at the result of the DMF sys.fn_hadr_backup_is_preferred_replica() in this context. I put here a simplified sample portion of the TSQL code used in our DMK:<\/p>\n<p>&nbsp;<\/p>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">USE<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: blue\">master<span style=\"color: gray\">;<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">GO<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">DECLARE<span style=\"font-size: 9.5pt;font-family: Consolas\"> @db_name <span style=\"color: blue\">SYSNAME<span style=\"color: gray\">;<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">SELECT<span style=\"font-size: 9.5pt;font-family: Consolas\"> @db_name <span style=\"color: gray\">= name <\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">FROM<span style=\"font-size: 9.5pt;font-family: Consolas\"> <span style=\"color: green\">sys<span style=\"color: gray\">.<span style=\"color: green\">databases <span style=\"color: blue\">WHERE name <span style=\"color: gray\">= <span style=\"color: red\">N&#8217;DUMMY&#8217;<span style=\"color: gray\">;<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas;color: blue\">SELECT<\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: fuchsia\">@@SERVERNAME <span style=\"color: blue\">AS server_name<span style=\"color: gray\">,<\/span><\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @db_name <span style=\"color: blue\">AS database_name<span style=\"color: gray\">, <\/span><\/span><\/span><\/div>\n<div style=\"margin-bottom: 0.0001pt;line-height: normal;background: none repeat scroll 0% 0% #d9d9d9\"><span style=\"font-size: 9.5pt;font-family: Consolas\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: green\">sys<span style=\"color: gray\">.fn_hadr_backup_is_preferred_replica<span style=\"color: gray\">(@db_name<span style=\"color: gray\">) <span style=\"color: blue\">AS fn_result<span style=\"color: gray\">;<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<p>&nbsp;<\/p>\n<p>Concerning the primary:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_backup_function_result_primaryjpg.jpg\" alt=\"blog_37_-_backup_function_result_primaryjpg\" width=\"230\" height=\"35\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Concerning the secondary\u00a0:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_backup_function_result_secondary.jpg\" alt=\"blog_37_-_backup_function_result_secondary\" width=\"219\" height=\"35\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>If you perform the same by configuring this time the replica names in upper case, you will notice that the issue will disappear. When I think about this issue, it&#8217;s true that in almost cases customers prefer to use the assistant wizard to configure availability groups and in this case do you notice that the replica names are always switched in upper case?<\/p>\n<p>There also exists a <a href=\"https:\/\/connect.microsoft.com\/SQLServer\/feedback\/details\/765317\/sys-fn-hadr-backup-is-preferred-replica-always-return-zero-for-availabilty-database\">Microsoft connect item<\/a> about this problem but unfortunately it seems that it will not be solved by Microsoft \u2026 so be careful when you implement availability groups by script.<\/p>\n<p>See you on the next availability group ventury!<\/p>\n<p>By David Barbarin<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of days ago, I faced a weird backup issue with SQL Server AlwaysOn and availability groups at one of my customer (thank to him to point out this issue \ud83d\ude42 ). After installing our DMK tool (Database Management Kit) about database maintenance for AlwaysOn, my customer noticed that their databases have not backed [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":4476,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[199],"tags":[297,84,51],"type_dbi":[],"class_list":["post-4475","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hardware-storage","tag-availability-groups","tag-high-availability","tag-sql-server"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Weird issue with sys.fn_hadr_backup_is_preferred_replica() function - dbi Blog<\/title>\n<meta name=\"description\" content=\"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function\" \/>\n<meta property=\"og:description\" content=\"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-30T17:11:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_powershell_script.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"575\" \/>\n\t<meta property=\"og:image:height\" content=\"245\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Microsoft Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Microsoft Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/\"},\"author\":{\"name\":\"Microsoft Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\"},\"headline\":\"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function\",\"datePublished\":\"2015-03-30T17:11:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/\"},\"wordCount\":563,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_37_-_powershell_script.jpg\",\"keywords\":[\"Availability groups\",\"High availability\",\"SQL Server\"],\"articleSection\":[\"Hardware &amp; Storage\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/\",\"name\":\"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_37_-_powershell_script.jpg\",\"datePublished\":\"2015-03-30T17:11:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\"},\"description\":\"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_37_-_powershell_script.jpg\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/blog_37_-_powershell_script.jpg\",\"width\":575,\"height\":245},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\",\"name\":\"Microsoft Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"caption\":\"Microsoft Team\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/microsoft-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function - dbi Blog","description":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/","og_locale":"en_US","og_type":"article","og_title":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function","og_description":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function","og_url":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/","og_site_name":"dbi Blog","article_published_time":"2015-03-30T17:11:17+00:00","og_image":[{"width":575,"height":245,"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_powershell_script.jpg","type":"image\/jpeg"}],"author":"Microsoft Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Microsoft Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/"},"author":{"name":"Microsoft Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"headline":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function","datePublished":"2015-03-30T17:11:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/"},"wordCount":563,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_powershell_script.jpg","keywords":["Availability groups","High availability","SQL Server"],"articleSection":["Hardware &amp; Storage"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/","url":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/","name":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_powershell_script.jpg","datePublished":"2015-03-30T17:11:17+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"description":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_powershell_script.jpg","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/blog_37_-_powershell_script.jpg","width":575,"height":245},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/weird-issue-with-sysfnhadrbackupispreferredreplica-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Weird issue with sys.fn_hadr_backup_is_preferred_replica() function"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4","name":"Microsoft Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","caption":"Microsoft Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/microsoft-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/4475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=4475"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/4475\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/4476"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=4475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=4475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=4475"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=4475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}