Skip to content

Commit ee9c0ac

Browse files
authored
Merge pull request #5474 from LowlyDBA/patch-14
Update sys-fn-hadr-is-primary-replica-transact-sql.md
2 parents c0f9273 + 0e503ad commit ee9c0ac

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

docs/relational-databases/system-functions/sys-fn-hadr-is-primary-replica-transact-sql.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ ms.author: mikeray
3131

3232
## Syntax
3333

34-
```
35-
34+
```syntaxsql
3635
sys.fn_hadr_is_primary_replica ( 'dbname' )
3736
```
3837

@@ -46,21 +45,20 @@ sys.fn_hadr_is_primary_replica ( 'dbname' )
4645
## Remarks
4746
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.
4847

49-
```
48+
```sql
5049
If sys.fn_hadr_is_primary_replica ( @dbname ) <> 1
5150
BEGIN
5251
-- If this is not the primary replica, exit (probably without error).
5352
END
5453
-- If this is the primary replica, continue to do the backup.
55-
5654
```
5755

5856
## Examples
5957

6058
### A. Using sys.fn_hadr_is_primary_replica
6159
The following example returns 1 if the specified database on the local instance is the primary replica.
6260

63-
```
61+
```sql
6462
SELECT sys.fn_hadr_is_primary_replica ('TestDB');
6563
GO
6664
```

0 commit comments

Comments
 (0)