You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use this function to conveniently determine whether the local instance is hosting the primary replica of the specified availability database. Sample code could be similar to the following.
48
47
49
-
```
48
+
```sql
50
49
If sys.fn_hadr_is_primary_replica ( @dbname ) <>1
51
50
BEGIN
52
51
-- If this is not the primary replica, exit (probably without error).
53
52
END
54
53
-- If this is the primary replica, continue to do the backup.
55
-
56
54
```
57
55
58
56
## Examples
59
57
60
58
### A. Using sys.fn_hadr_is_primary_replica
61
59
The following example returns 1 if the specified database on the local instance is the primary replica.
0 commit comments