Skip to content

Commit 4f6c089

Browse files
authored
Merge pull request #31635 from rwestMSFT/rw-0122-system-stored-procedures-039
System stored procedures: Refresh batch 039
2 parents 261c74f + 41f65c9 commit 4f6c089

44 files changed

Lines changed: 2727 additions & 2292 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/relational-databases/system-stored-procedures/sp-external-policy-refresh-transact-sql.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ Forces immediate download of latest published policies for the whole instance (f
2828
## Syntax
2929

3030
```syntaxsql
31-
sp_external_policy_refresh [ @type = ] 'type'
31+
sp_external_policy_refresh [ @type = ] 'type'
32+
[ ; ]
3233
```
3334

3435
## Arguments
3536

3637
#### [ @type = ] '*type*'
3738

38-
Type can be: *reload* (complete policy download) or *update* (incremental policy download). Default type is *update*.
39+
Type can be `reload` (complete policy download) or `update` (incremental policy download). Default type is `update`.
3940

4041
## Return code values
4142

42-
0 (success) or a nonzero number (failure)
43+
`0` (success) or a nonzero number (failure).
4344

4445
## Permissions
4546

46-
Requires ALTER SERVER STATE (covered by CONTROL SERVER) permission.
47+
Requires `ALTER SERVER STATE` (covered by `CONTROL SERVER`) permission.
4748

4849
## Examples
4950

@@ -60,7 +61,7 @@ EXEC sp_external_policy_refresh @type = 'reload'
6061
The following example downloads policies incrementally by using the default type 'update'.
6162

6263
```sql
63-
EXEC sp_external_policy_refresh
64+
EXEC sp_external_policy_refresh;
6465
```
6566

6667
## Related content
Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
title: sp_readerrorlog (Transact-SQL)
3-
description: sp_readerrorlog (Transact-SQL)
3+
description: sp_readerrorlog allows you to read the contents of the SQL Server or SQL Server Agent error log file and filter on keywords.
44
author: pijocoder
55
ms.author: jopilov
6-
ms.date: "02/08/2022"
6+
ms.reviewer: randolphwest
7+
ms.date: 08/22/2024
78
ms.service: sql
89
ms.subservice: system-objects
910
ms.topic: "reference"
@@ -20,77 +21,78 @@ dev_langs:
2021
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
2122

2223
Allows you to read the contents of the SQL Server or SQL Server Agent error log file and filter on keywords.
23-
24-
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
25-
26-
## Syntax
27-
28-
```sql
29-
sp_readerrorlog
30-
@p1 int = 0,
31-
@p2 int = NULL,
32-
@p3 nvarchar(4000) = NULL,
33-
@p4 nvarchar(4000) = NULL
34-
```
24+
25+
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
26+
27+
## Syntax
28+
29+
```syntaxsql
30+
sp_readerrorlog
31+
[ [ @p1 = ] p1 ]
32+
[ , [ @p2 = ] p2 ]
33+
[ , [ @p3 = ] N'p3' ]
34+
[ , [ @p4 = ] N'p4' ]
35+
[ ; ]
36+
```
3537

3638
## Arguments
3739

38-
#### [@p1 = ] 'log_number'
40+
#### [ @p1 = ] *p1*
41+
42+
The integer value of the log you want to view. *@p1* is **int**, with a default of `0`. The current error log has a value of `0`. The previous is `1` (`ERRORLOG.1`), the one before previous is 2 (`ERRORLOG.2`), and so on.
3943

40-
Is the integer (int) value of the log you want to view. The current error log has a value of 0, the previous is 1 (Errorlog.1), the one before previous is 2 (Errorlog.2), and so on.
44+
#### [ @p2 = ] *p2*
4145

42-
#### [@p2 = ] 'product ID'
46+
The integer value for the product whose log you want to view. *@p2* is **int**, with a default of `NULL`. Use `1` for SQL Server or `2` SQL Server Agent. If a value isn't specified, the SQL Server product is used.
4347

44-
Is the integer (int) value for the product whose log you want to view. Use 1 for SQL Server or 2 SQL Server Agent. If a value isn't specified, the SQL Server product is used
48+
#### [ @p3 = ] N'*p3*'
4549

46-
#### [@p3 = ] 'string_to_search'
50+
The string value for a string you want to filter on when viewing the error log. *@p3* is **nvarchar(4000)**, with a default of `NULL`.
4751

48-
Is the string value for a string you want to filter on when viewing the error log. This value is **nvarchar(4000)** and has a default of NULL.
52+
#### [ @p4 = ] N'*p4*'
4953

50-
#### [@p4 = ] 'string_to_search'
54+
The string value for an additional string you want to filter on to further refine the search when viewing the error log. *@p4* is **nvarchar(4000)**, with a default of `NULL`. This parameter provides an extra filter to the first string search *@p3*.
5155

52-
Is the string value for an additional string you want to filter on to further refine the search when viewing the error log. This value is **nvarchar(4000)** and has a default of NULL. This provides an additional filter to the first string search @p3.
56+
## Return code values
5357

54-
## Return Code Values
58+
None.
5559

56-
No return code
57-
58-
## Result Sets
60+
## Result set
61+
62+
Displays the content of the requested error log. If filter strings are used, only the lines that match those strings are displayed.
5963

60-
Displays the content of the requested error log. If filter strings are used only the lines that match those strings are displayed.
61-
6264
## Remarks
6365

64-
Every time [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is started, the current error log is renamed to **errorlog.1**; **errorlog.1** becomes **errorlog.2**, **errorlog.2** becomes **errorlog.3**, and so on. **sp_readerrorlog** enables you to read any of these error log files as long as the files exist.
65-
66+
Every time [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] is started, the current error log is renamed to `ERRORLOG.1`; `ERRORLOG.1` becomes `ERRORLOG.2`, `ERRORLOG.2` becomes `ERRORLOG.3`, and so on. `sp_readerrorlog` enables you to read any of these error log files as long as the files exist.
67+
6668
## Permissions
6769

68-
Execute permissions for **sp_readerrorlog** are restricted to members of the **sysadmin** fixed server role.
69-
70+
Execute permissions for `sp_readerrorlog` are restricted to members of the **sysadmin** fixed server role.
71+
7072
## Examples
7173

72-
The following example cycles the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] error log.
74+
The following example cycles the [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] error log.
7375

7476
### A. Read the current SQL Server error log
7577

76-
```sql
77-
EXEC sp_readerrorlog;
78-
```
79-
78+
```sql
79+
EXEC sp_readerrorlog;
80+
```
81+
8082
### B. Show the previous SQL Server Agent error log
8183

8284
```sql
83-
exec sp_readerrorlog 1, 2;
85+
EXEC sp_readerrorlog 1, 2;
8486
```
8587

8688
### C. Find log messages that indicate a database is starting up
8789

8890
```sql
89-
exec sp_readerrorlog 0, 1, 'database', 'start'
91+
EXEC sp_readerrorlog 0, 1, 'database', 'start';
9092
```
9193

92-
## See Also
94+
## Related content
9395

94-
- [System Stored Procedures (Transact-SQL)](../../relational-databases/system-stored-procedures/system-stored-procedures-transact-sql.md)
95-
- [sp_cycle_errorlog (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-cycle-errorlog-transact-sql.md)
96-
- [sp_cycle_agent_errorlog (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-cycle-agent-errorlog-transact-sql.md)
96+
- [System stored procedures (Transact-SQL)](system-stored-procedures-transact-sql.md)
97+
- [sp_cycle_errorlog (Transact-SQL)](sp-cycle-errorlog-transact-sql.md)
98+
- [sp_cycle_agent_errorlog (Transact-SQL)](sp-cycle-agent-errorlog-transact-sql.md)
Lines changed: 70 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
title: "sp_refresh_log_shipping_monitor (Transact-SQL)"
3-
description: "sp_refresh_log_shipping_monitor (Transact-SQL)"
3+
description: sp_refresh_log_shipping_monitor refreshes the remote monitor tables with the latest information from a given primary or secondary server.
44
author: markingmyname
55
ms.author: maghan
6-
ms.date: "03/14/2017"
6+
ms.reviewer: randolphwest
7+
ms.date: 08/22/2024
78
ms.service: sql
89
ms.subservice: system-objects
910
ms.topic: "reference"
@@ -16,64 +17,72 @@ dev_langs:
1617
- "TSQL"
1718
---
1819
# sp_refresh_log_shipping_monitor (Transact-SQL)
20+
1921
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
2022

21-
This stored procedure refreshes the remote monitor tables with the latest information from a given primary or secondary server for the specified log shipping agent. The procedure is invoked on the primary or secondary server.
22-
23-
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
24-
25-
## Syntax
26-
27-
```
28-
29-
sp_refresh_log_shipping_monitor
30-
[ @agent_id = ] 'agent_id',
31-
[ @agent_type = ] 'agent_type'
32-
[ @database = ] 'database'
33-
[ @mode ] n
34-
```
35-
36-
## Arguments
37-
`[ @agent_id = ] 'agent_id'`
38-
The primary ID for backup or the secondary ID for copy or restore. *agent_id* is **uniqueidentifier** and cannot be NULL.
39-
40-
`[ @agent_type = ] 'agent_type'`
41-
The type of log shipping job.
42-
43-
0 = Backup.
44-
45-
1 = Copy.
46-
47-
2 = Restore.
48-
49-
*agent_type* is **tinyint** and cannot be NULL.
50-
51-
`[ @database = ] 'database'`
52-
The primary or secondary database used by logging by backup or restore agents.
53-
54-
`[ @mode ] n`
55-
Specifies whether to refresh the monitor data or clean it. The data type of *m* is tinyint, and the supported values are:
56-
57-
1 = refresh (This is the default value.)
58-
59-
2 = delete
60-
61-
## Return Code Values
62-
0 (success) or 1 (failure)
63-
64-
## Result Sets
65-
None.
66-
67-
## Remarks
68-
**sp_refresh_log_shipping_monitor** refreshes the **log_shipping_monitor_primary**, **log_shipping_monitor_secondary**, **log_shipping_monitor_history_detail**, and **log_shipping_monitor_error_detail** tables with any session information that has not already been transferred. This allows you to synchronize the monitor server with primary or a secondary server when the monitor has been out of sync for awhile. Additionally, it allows you to clean up the monitor information on monitor server if necessary.
69-
70-
**sp_refresh_log_shipping_monitor** must be run from the **master** database on the primary or secondary server.
71-
72-
## Permissions
73-
Only members of the **sysadmin** fixed server role can run this procedure.
74-
75-
## See Also
76-
[About Log Shipping (SQL Server)](../../database-engine/log-shipping/about-log-shipping-sql-server.md)
77-
[System Stored Procedures (Transact-SQL)](../../relational-databases/system-stored-procedures/system-stored-procedures-transact-sql.md)
78-
79-
23+
This stored procedure refreshes the remote monitor tables with the latest information from a given primary or secondary server for the specified log shipping agent. The procedure is invoked on the primary or secondary server.
24+
25+
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
26+
27+
## Syntax
28+
29+
```syntaxsql
30+
sp_refresh_log_shipping_monitor
31+
[ @agent_id = ] 'agent_id'
32+
, [ @agent_type = ] agent_type
33+
[ , [ @database = ] N'database' ]
34+
, [ @mode = ] mode
35+
[ ; ]
36+
```
37+
38+
## Arguments
39+
40+
#### [ @agent_id = ] '*agent_id*'
41+
42+
The primary ID for backup or the secondary ID for copy or restore. *@agent_id* is **uniqueidentifier**, with no default, and can't be `NULL`.
43+
44+
#### [ @agent_type = ] *agent_type*
45+
46+
The type of log shipping job. *@agent_type* is **tinyint**, and can't be `NULL`. *@agent_type* must be one of these values:
47+
48+
| Value | Description |
49+
| --- | --- |
50+
| `0` | Backup |
51+
| `1` | Copy |
52+
| `2` | Restore |
53+
54+
#### [ @database = ] N'*database*'
55+
56+
The primary or secondary database used by logging by backup or restore agents. *@database* is **sysname**, with a default of `NULL`.
57+
58+
#### [ @mode = ] *mode*
59+
60+
Specifies whether to refresh the monitor data or clean it. *@mode* is **tinyint**, and can be one of these values:
61+
62+
| Value | Description |
63+
| --- | --- |
64+
| `1` (default) | Refresh |
65+
| `2` | Delete |
66+
67+
## Return code values
68+
69+
`0` (success) or `1` (failure).
70+
71+
## Result set
72+
73+
None.
74+
75+
## Remarks
76+
77+
`sp_refresh_log_shipping_monitor` refreshes the `log_shipping_monitor_primary`, `log_shipping_monitor_secondary`, `log_shipping_monitor_history_detail`, and `log_shipping_monitor_error_detail` tables with any session information that isn't already transferred. `sp_refresh_log_shipping_monitor` allows you to synchronize the monitor server with primary or a secondary server when the monitor is out of sync for some time. Additionally, it allows you to clean up the monitor information on monitor server if necessary.
78+
79+
`sp_refresh_log_shipping_monitor` must be run from the `master` database on the primary or secondary server.
80+
81+
## Permissions
82+
83+
Only members of the **sysadmin** fixed server role can run this procedure.
84+
85+
## Related content
86+
87+
- [About log shipping (SQL Server)](../../database-engine/log-shipping/about-log-shipping-sql-server.md)
88+
- [System stored procedures (Transact-SQL)](system-stored-procedures-transact-sql.md)

0 commit comments

Comments
 (0)