Skip to content

Commit 390b998

Browse files
20210819 1358 update sp_helptext for azure synapse
1 parent 8e86cc8 commit 390b998

5 files changed

Lines changed: 98 additions & 83 deletions

File tree

docs/relational-databases/security/metadata-visibility-configuration.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: "Metadata Visibility Configuration | Microsoft Docs"
2+
title: "Metadata Visibility Configuration"
33
description: Learn how to configure metadata visibility for securables that a user owns or has been granted permission to in SQL Server.
44
ms.custom: ""
5-
ms.date: "03/17/2017"
5+
ms.date: "08/19/2021"
66
ms.prod: sql
77
ms.prod_service: "database-engine, sql-database, synapse-analytics, pdw"
88
ms.reviewer: ""
@@ -17,7 +17,6 @@ helpviewer_keywords:
1717
- "displaying metadata"
1818
- "database metadata [SQL Server]"
1919
- "metadata [SQL Server], permissions"
20-
ms.assetid: 50d2e015-05ae-4014-a1cd-4de7866ad651
2120
author: VanMSFT
2221
ms.author: vanto
2322
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
@@ -86,7 +85,7 @@ GO
8685

8786
SQL modules, such as stored procedures and triggers, run under the security context of the caller and, therefore, have limited metadata accessibility. For example, in the following code, when the stored procedure tries to access metadata for the table `myTable` on which the caller has no rights, an empty result set is returned. In earlier releases of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], a row is returned.
8887

89-
```
88+
```sql
9089
CREATE PROCEDURE assumes_caller_can_access_metadata
9190
BEGIN
9291
SELECT name, object_id
@@ -103,7 +102,7 @@ GO
103102
> [!NOTE]
104103
> The following example uses the [sys.objects](../../relational-databases/system-catalog-views/sys-objects-transact-sql.md) catalog view instead of the [sys.sysobjects](../../relational-databases/system-compatibility-views/sys-sysobjects-transact-sql.md) compatibility view.
105104
106-
```
105+
```sql
107106
CREATE PROCEDURE does_not_assume_caller_can_access_metadata
108107
WITH EXECUTE AS OWNER
109108
AS
@@ -125,7 +124,7 @@ GO
125124

126125
The following metadata is not subject to forced disclosure:
127126

128-
- The value stored in the **provider_string** column of **sys.servers**. A user that does not have ALTER ANY LINKED SERVER permission will see a NULL value in this column.
127+
- The value stored in the `provider_string` column of `sys.servers`. A user that does not have ALTER ANY LINKED SERVER permission will see a NULL value in this column.
129128

130129
- Source definition of a user-defined object such as a stored procedure or trigger. The source code is visible only when one of the following is true:
131130

@@ -135,17 +134,17 @@ GO
135134

136135
- The definition columns found in the following catalog views:
137136

138-
- **sys.all_sql_modules**
139-
- **sys.server_sql_modules**
140-
- **sys.default_constraints**
141-
- **sys.numbered_procedures**
142-
- **sys.sql_modules**
143-
- **sys.check_constraints**
144-
- **sys.computed_columns**
137+
- `sys.all_sql_modules`
138+
- `sys.server_sql_modules`
139+
- `sys.default_constraints`
140+
- `sys.numbered_procedures`
141+
- `sys.sql_modules`
142+
- `sys.check_constraints`
143+
- `sys.computed_columns`
145144

146-
- The **ctext** column in the **syscomments** compatibility view.
145+
- The `ctext` column in the `syscomments` compatibility view.
147146

148-
- The output of the **sp_helptext** procedure.
147+
- The output of the `sp_helptext` procedure.
149148

150149
- The following columns in the information schema views:
151150

@@ -158,10 +157,13 @@ GO
158157

159158
- OBJECT_DEFINITION() function
160159

161-
- The value stored in the password_hash column of **sys.sql_logins**. A user that does not have CONTROL SERVER permission will see a NULL value in this column.
160+
- The value stored in the password_hash column of `sys.sql_logins`. A user that does not have CONTROL SERVER permission will see a NULL value in this column.
162161

163162
> [!NOTE]
164-
> The SQL definitions of built-in system procedures and functions are publicly visible through the **sys.system_sql_modules** catalog view, the **sp_helptext** stored procedure, and the OBJECT_DEFINITION() function.
163+
> The SQL definitions of built-in system procedures and functions are publicly visible through the `sys.system_sql_modules` catalog view, the `sp_helptext` stored procedure, and the OBJECT_DEFINITION() function.
164+
165+
> [!NOTE]
166+
> The system stored procedure `sp_helptext` is not supported in Azure Synapse Analytics. Instead, use the `OBJECT_DEFINITION` system function or `sys.sql_modules` object catalog view.
165167
166168
## General Principles of Metadata Visibility
167169
The following are some general principles to consider regarding metadata visibility:
@@ -194,11 +196,12 @@ GO
194196
The visibility of subcomponents, such as indexes, check constraints, and triggers is determined by permissions on the parent. These subcomponents do not have grantable permissions. For example, if a user has been granted some permission on a table, the user can view the metadata for the tables, columns, indexes, check constraints, triggers, and other such subcomponents. Another example is granting SELECT on only an individual column of a given table: this will allow the grantee to view the matadata of the whole table, including all columns. One way to think of it, is that the VIEW DEFINITION permission only works on entity-level (the table in this case) and is not available for Sub-entity lists (such as column or security expressions).
195197

196198
The following code demonstrates this behavior:
199+
197200
```sql
198201
CREATE TABLE t1
199202
(
200-
c1 int,
201-
c2 varchar
203+
c1 int,
204+
c2 varchar
202205
);
203206
GO
204207
CREATE USER testUser WITHOUT LOGIN;

docs/relational-databases/stored-procedures/view-the-definition-of-a-stored-procedure.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: "View the Definition of a Stored Procedure | Microsoft Docs"
2+
title: "View the Definition of a Stored Procedure"
33
description: Learn how to view the definition of procedure in Object Explorer and by using a system stored procedure, system function, and object catalog view in the Query Editor.
44
ms.custom: ""
5-
ms.date: "03/14/2017"
5+
ms.date: "08/19/2021"
66
ms.prod: sql
77
ms.technology: stored-procedures
88
ms.reviewer: ""
@@ -12,7 +12,6 @@ helpviewer_keywords:
1212
- "definition of stored procedure"
1313
- "viewing stored procedures"
1414
- "displaying stored procedures"
15-
ms.assetid: 93318587-a0c5-4788-946f-3b5dc8372ea9
1615
author: WilliamDAssafMSFT
1716
ms.author: wiassaf
1817
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
@@ -41,6 +40,9 @@ This topic describes how to view the definition of procedure in Object Explorer
4140

4241
Object Catalog View: **sys.sql_modules**
4342
The visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user has been granted some permission. For more information, see [Metadata Visibility Configuration](../../relational-databases/security/metadata-visibility-configuration.md).
43+
44+
> [!NOTE]
45+
> The system stored procedure `sp_helptext` is not supported in Azure Synapse Analytics. Instead, use `OBJECT_DEFINITION` system function or `sys.sql_modules` object catalog view. Samples are provided later in this article.
4446
4547
## <a name="Procedures"></a> How to View the Definition of a Stored Procedure
4648
You can use one of the following:
@@ -61,47 +63,50 @@ This topic describes how to view the definition of procedure in Object Explorer
6163
4. Select **New Query Editor Window**. This will display the procedure definition.
6264

6365
### <a name="TsqlProcedure"></a> Using Transact-SQL
64-
**To view the definition of a procedure in Query Editor**
66+
67+
#### To view the definition of a procedure in Query Editor
6568

6669
System Stored Procedure: **sp_helptext**
6770
1. In Object Explorer, connect to an instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
6871

6972
2. On the toolbar, click **New Query**.
7073

71-
3. In the query window, enter the following statement that uses the **sp_helptext** system stored procedure. Change the database name and stored procedure name to reference the database and stored procedure that you want.
74+
3. In the query window, enter the following statement that uses the `sp_helptext` system stored procedure. Change the database name and stored procedure name to reference the database and stored procedure that you want.
7275

73-
```
76+
```sql
7477
USE AdventureWorks2012;
7578
GO
7679
EXEC sp_helptext N'AdventureWorks2012.dbo.uspLogError';
7780
```
7881

79-
System Function: **OBJECT_DEFINITION**
82+
#### System Function: **OBJECT_DEFINITION**
83+
8084
1. In Object Explorer, connect to an instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
8185

8286
2. On the toolbar, click **New Query**.
8387

84-
3. In the query window, enter the following statements that use the **OBJECT_DEFINITION** system function. Change the database name and stored procedure name to reference the database and stored procedure that you want.
88+
3. In the query window, enter the following statements that use the `OBJECT_DEFINITION` system function. Change the database name and stored procedure name to reference the database and stored procedure that you want.
8589

86-
```
90+
```sql
8791
USE AdventureWorks2012;
8892
GO
8993
SELECT OBJECT_DEFINITION (OBJECT_ID(N'AdventureWorks2012.dbo.uspLogError'));
9094
```
9195

92-
Object Catalog View: **sys.sql_modules**
96+
#### <a id=sql_modules></a> Object Catalog View: **sys.sql_modules**
97+
9398
1. In Object Explorer, connect to an instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
9499

95100
2. On the toolbar, click **New Query**.
96101

97-
3. In the query window, enter the following statements that use the **sys.sql_modules** catalog view. Change the database name and stored procedure name to reference the database and stored procedure that you want.
102+
3. In the query window, enter the following statements that use the `sys.sql_modules` catalog view. Change the database name and stored procedure name to reference the database and stored procedure that you want.
98103

99-
```
104+
```sql
100105
USE AdventureWorks2012;
101106
GO
102-
SELECT definition
107+
SELECT [definition]
103108
FROM sys.sql_modules
104-
WHERE object_id = (OBJECT_ID(N'AdventureWorks2012.dbo.uspLogError'));
109+
WHERE object_id = (OBJECT_ID(N'dbo.uspLogError'));
105110
```
106111

107112
## See Also

docs/relational-databases/system-stored-procedures/sp-helptext-transact-sql.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
description: "sp_helptext (Transact-SQL)"
3-
title: "sp_helptext (Transact-SQL) | Microsoft Docs"
3+
title: "sp_helptext (Transact-SQL)"
44
ms.custom: ""
5-
ms.date: "03/14/2017"
5+
ms.date: "08/19/2021"
66
ms.prod: sql
77
ms.prod_service: "database-engine, sql-database"
88
ms.reviewer: ""
@@ -15,7 +15,6 @@ dev_langs:
1515
- "TSQL"
1616
helpviewer_keywords:
1717
- "sp_helptext"
18-
ms.assetid: 24135456-05f0-427c-884b-93cf38dd47a8
1918
author: markingmyname
2019
ms.author: maghan
2120
monikerRange: "=azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
@@ -51,7 +50,10 @@ sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name ]
5150
|**Text**|**nvarchar(255)**|Object definition|
5251

5352
## Remarks
54-
sp_helptext displays the definition that is used to create an object in multiple rows. Each row contains 255 characters of the [!INCLUDE[tsql](../../includes/tsql-md.md)] definition. The definition resides in the **definition** column in the [sys.sql_modules](../../relational-databases/system-catalog-views/sys-sql-modules-transact-sql.md) catalog view.
53+
sp_helptext displays the definition that is used to create an object in multiple rows. Each row contains 255 characters of the [!INCLUDE[tsql](../../includes/tsql-md.md)] definition. The definition resides in the `definition` column in the [sys.sql_modules](../../relational-databases/system-catalog-views/sys-sql-modules-transact-sql.md) catalog view.
54+
55+
> [!NOTE]
56+
> The system stored procedure `sp_helptext` is not supported in Azure Synapse Analytics. Instead, use `OBJECT_DEFINITION` system function or `sys.sql_modules` object catalog view for equivalent results.
5557
5658
## Permissions
5759
Requires membership in the **public** role. System object definitions are publicly visible. The definition of user objects is visible to the object owner or grantees that have any one of the following permissions: ALTER, CONTROL, TAKE OWNERSHIP, or VIEW DEFINITION.
@@ -61,7 +63,7 @@ sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name ]
6163
### A. Displaying the definition of a trigger
6264
The following example displays the definition of the trigger `dEmployee` in the [!INCLUDE[ssSampleDBobject](../../includes/sssampledbobject-md.md)]database.
6365

64-
```
66+
```sql
6567
USE AdventureWorks2012;
6668
GO
6769
EXEC sp_helptext 'HumanResources.dEmployee';
@@ -71,7 +73,7 @@ GO
7173
### B. Displaying the definition of a computed column
7274
The following example displays the definition of the computed column `TotalDue` on the `SalesOrderHeader` table in the [!INCLUDE[ssSampleDBobject](../../includes/sssampledbobject-md.md)] database.
7375

74-
```
76+
```sql
7577
USE AdventureWorks2012;
7678
GO
7779
sp_helptext @objname = N'AdventureWorks2012.Sales.SalesOrderHeader', @columnname = TotalDue ;

docs/relational-databases/views/get-information-about-a-view.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
description: "Get Information About a View"
3-
title: "Get Information About a View | Microsoft Docs"
3+
title: "Get Information About a View"
44
ms.custom: ""
5-
ms.date: "03/14/2017"
5+
ms.date: "08/19/2021"
66
ms.prod: sql
77
ms.prod_service: "database-engine, sql-database, synapse-analytics, pdw"
88
ms.reviewer: ""
@@ -19,7 +19,6 @@ helpviewer_keywords:
1919
- "viewing view information"
2020
- "status information [SQL Server], views"
2121
- "view dependencies"
22-
ms.assetid: 05a73e33-8f85-4fb6-80c1-1b659e753403
2322
author: WilliamDAssafMSFT
2423
ms.author: wiassaf
2524
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
@@ -182,7 +181,7 @@ monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-s
182181

183182
3. Copy and paste one of the following examples into the query window and click **Execute**.
184183

185-
```
184+
```sql
186185
USE AdventureWorks2012;
187186
GO
188187
SELECT definition, uses_ansi_nulls, uses_quoted_identifier, is_schema_bound
@@ -191,18 +190,21 @@ monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-s
191190
GO
192191
```
193192

194-
```
193+
```sql
195194
USE AdventureWorks2012;
196195
GO
197196
SELECT OBJECT_DEFINITION (OBJECT_ID('HumanResources.vEmployee')) AS ObjectDefinition;
198197
GO
199198
```
200199

201-
```
200+
```sql
202201
EXEC sp_helptext 'HumanResources.vEmployee';
203202
```
204203

205204
For more information, see [sys.sql_modules &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-sql-modules-transact-sql.md), [OBJECT_DEFINITION &#40;Transact-SQL&#41;](../../t-sql/functions/object-definition-transact-sql.md) and [sp_helptext &#40;Transact-SQL&#41;](../../relational-databases/system-stored-procedures/sp-helptext-transact-sql.md).
205+
206+
> [!NOTE]
207+
> The system stored procedure `sp_helptext` is not supported in Azure Synapse Analytics. Instead, use the `OBJECT_DEFINITION` system function or `sys.sql_modules` object catalog view.
206208

207209
#### To get the dependencies of a view
208210

@@ -212,7 +214,7 @@ monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-s
212214

213215
3. Copy and paste the following example into the query window and click **Execute**.
214216

215-
```
217+
```sql
216218
USE AdventureWorks2012;
217219
GO
218220
SELECT OBJECT_NAME(referencing_id) AS referencing_entity_name,

0 commit comments

Comments
 (0)