|
1 | 1 | --- |
2 | 2 | author: rwestMSFT |
3 | 3 | ms.author: randolphwest |
4 | | -ms.date: 12/30/2022 |
| 4 | +ms.date: 10/22/2023 |
5 | 5 | ms.service: sql-database |
6 | 6 | ms.topic: include |
7 | 7 | --- |
8 | | -Some Transact-SQL code examples written for SQL Server on-premises need small changes to run in the cloud. One category of such code examples involves system views whose name prefixes differ slightly between the two database systems: |
| 8 | +Some Transact-SQL code examples written for SQL Server need small changes to run in Azure. One category of such code examples involves catalog views whose name prefixes differ depending on the database engine type: |
9 | 9 |
|
10 | | -- **server_** - *prefix for SQL Server and Azure SQL Managed Instance* |
11 | | -- **database_** - *prefix for Azure SQL Database and SQL Managed Instance* |
| 10 | +- `server_` - *prefix for SQL Server and Azure SQL Managed Instance* |
| 11 | +- `database_` - *prefix for Azure SQL Database and SQL Managed Instance* |
12 | 12 |
|
13 | | -Azure SQL Database supports only database-scoped sessions. [SQL Server Management Studio](../../ssms/sql-server-management-studio-ssms.md) (SSMS) fully supports database-scoped sessions for Azure SQL Database: an **Extended Events** node containing database-scoped sessions appears under each database in [Object Explorer](../../ssms/object/object-explorer.md). |
| 13 | +Azure SQL Database supports only database-scoped event sessions. [SQL Server Management Studio](../../ssms/sql-server-management-studio-ssms.md) (SSMS) fully supports database-scoped event sessions for Azure SQL Database: an **Extended Events** node containing database-scoped sessions appears under each database in [Object Explorer](../../ssms/object/object-explorer.md). |
14 | 14 |
|
15 | | -Azure SQL Managed Instance supports both database-scoped sessions and server-scoped sessions. Server-scoped sessions are recommended for managed instances. SSMS fully supports server-scoped sessions for SQL Managed Instance: an **Extended Events** node containing all server-scoped sessions appears under the **Management** folder for each managed instance in Object Explorer. |
| 15 | +Azure SQL Managed Instance supports both database-scoped sessions and server-scoped sessions. SSMS fully supports server-scoped sessions for SQL Managed Instance: an **Extended Events** node containing all server-scoped sessions appears under the **Management** folder for each managed instance in Object Explorer. |
16 | 16 |
|
17 | 17 | > [!NOTE] |
18 | | -> Database-scoped sessions are not displayed in Object Explorer in SSMS for Azure SQL Managed Instance. Database-scoped sessions may only be queried and managed with Transact-SQL when using a managed instance. |
| 18 | +> Server-scoped sessions are recommended for managed instances. Database-scoped sessions aren't displayed in Object Explorer in SSMS for Azure SQL Managed Instance. Database-scoped sessions can only be queried and managed with Transact-SQL when using a managed instance. |
19 | 19 |
|
20 | | -For illustration, the following table lists and compares two subsets of the system views. For brevity, the subsets are restricted to view names that also contain the string `_event`. The subsets have differing name prefixes because they come from two different database systems. |
| 20 | +For illustration, the following table lists and compares two subsets of catalog views. For brevity, the subsets are restricted to view names that also contain the string `_event`. The subsets have differing name prefixes because they support different database engine types. |
21 | 21 |
|
22 | | -| Name from SQL Server | Name from cloud service | |
| 22 | +| Name in SQL Server and Azure SQL Managed Instance | Name in Azure SQL Database and Azure SQL Managed Instance | |
23 | 23 | | :--- | :--- | |
24 | 24 | | server_event_notifications<br />server_event_session_actions<br />server_event_session_events<br />server_event_session_fields<br />server_event_session_targets<br />server_event_sessions<br />server_events<br />server_trigger_events | database_event_session_actions<br />database_event_session_events<br />database_event_session_fields<br />database_event_session_targets<br />database_event_sessions | |
25 | 25 |
|
26 | | -The two lists in the preceding table were accurate as of March 2022. For an accurate list, run the following Transact-SQL SELECT statement: |
| 26 | +The two lists in the preceding table were accurate as of March 2022. For an up-to-date list, run the following Transact-SQL `SELECT` statement: |
27 | 27 |
|
28 | 28 | ```sql |
29 | 29 | SELECT name |
30 | 30 | FROM sys.all_objects |
31 | 31 | WHERE |
32 | | - (name LIKE 'database\_%' { ESCAPE '\' } OR |
33 | | - name LIKE 'server\_%' { ESCAPE '\' }) |
34 | | - AND name LIKE '%\_event%' { ESCAPE '\' } |
| 32 | + (name LIKE 'database[_]%' OR |
| 33 | + name LIKE 'server[_]%' ) |
| 34 | + AND name LIKE '%[_]event%' |
35 | 35 | AND type = 'V' |
| 36 | + AND SCHEMA_NAME(schema_id) = 'sys' |
36 | 37 | ORDER BY name; |
37 | 38 | ``` |
0 commit comments