Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit bb5bd62

Browse files
authored
Merge pull request #21429 from WilliamDAssafMSFT/20220310-ole-automation
20220310 correct ole automation applies to
2 parents 9aaf4ab + 9e549ba commit bb5bd62

4 files changed

Lines changed: 61 additions & 71 deletions

File tree

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: "OLE Automation Objects in Transact-SQL | Microsoft Docs"
2+
title: "OLE Automation Objects in Transact-SQL"
33
description: Learn how OLE Automation objects that are executed through stored procedures run in the address space of an instance of the SQL Server Database Engine.
44
ms.custom: ""
5-
ms.date: "03/16/2017"
5+
ms.date: "03/10/2022"
66
ms.prod: sql
77
ms.reviewer: ""
88
ms.technology: stored-procedures
@@ -12,54 +12,48 @@ helpviewer_keywords:
1212
- "batches [SQL Server], OLE Automation"
1313
- "OLE Automation [SQL Server]"
1414
- "OLE Automation [SQL Server], about OLE Automation"
15-
ms.assetid: a887d956-4cd0-400a-aa96-00d7abd7c44b
1615
author: WilliamDAssafMSFT
1716
ms.author: wiassaf
18-
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
17+
monikerRange: ">=sql-server-2016"
1918
---
2019
# OLE Automation Objects in Transact-SQL
21-
[!INCLUDE[SQL Server Azure SQL Database Synapse Analytics PDW ](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)]
20+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
21+
2222
[!INCLUDE[tsql](../../includes/tsql-md.md)] includes several system stored procedures that allow OLE Automation objects to be referenced in [!INCLUDE[tsql](../../includes/tsql-md.md)] batches, stored procedures, and triggers. These system stored procedures run as extended stored procedures, and the OLE Automation objects that are executed through the stored procedures run in the address space of an instance of the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)] in the same way that an extended stored procedure runs.
2323

2424
The OLE Automation stored procedures enable [!INCLUDE[tsql](../../includes/tsql-md.md)] batches to reference SQL-DMO objects and custom OLE Automation objects, such as objects that expose the **IDispatch** interface. A custom in-process OLE server that is created by using [!INCLUDE[msCoName](../../includes/msconame-md.md)] [!INCLUDE[vbprvb](../../includes/vbprvb-md.md)] must have an error handler (specified with the **On Error GoTo** statement) for the **Class_Initialize** and **Class_Terminate** subroutines. Unhandled errors in the **Class_Initialize** and **Class_Terminate** subroutines can cause unpredictable errors, such as an access violation in an instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)]. Error handlers for other subroutines are also recommended.
2525

26-
The first step when using an OLE Automation object in [!INCLUDE[tsql](../../includes/tsql-md.md)] is to call the **sp_OACreate** system stored procedure to create an instance of the object in the address space of the instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
26+
The first step when using an OLE Automation object in [!INCLUDE[tsql](../../includes/tsql-md.md)] is to call the `sp_OACreate` system stored procedure to create an instance of the object in the address space of the instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
2727

2828
After an instance of the object has been created, call the following stored procedures to work with the properties, methods, and error information related to the object:
2929

30-
- **sp_OAGetProperty** obtains the value of a property.
30+
- `sp_OAGetProperty` obtains the value of a property.
3131

32-
- **sp_OASetProperty** sets the value of a property.
32+
- `sp_OASetProperty` sets the value of a property.
3333

34-
- **sp_OAMethod** calls a method.
34+
- `sp_OAMethod` calls a method.
3535

36-
- **sp_OAGetErrorInfo** obtains the most recent error information.
36+
- `sp_OAGetErrorInfo` obtains the most recent error information.
3737

38-
When there is no more need for the object, call **sp_OADestroy** to deallocate the instance of the object created by using **sp_OACreate**.
38+
When there is no more need for the object, call `sp_OADestroy` to deallocate the instance of the object created by using `sp_OACreate`.
3939

40-
OLE Automation objects return data through property values and methods. **sp_OAGetProperty** and **sp_OAMethod** return these data values in the form of a result set.
40+
OLE Automation objects return data through property values and methods. The `sp_OAGetProperty` and `sp_OAMethod` procedures return these data values in the form of a result set.
4141

4242
The scope of an OLE Automation object is a batch. All references to the object must be contained in a single batch, stored procedure, or trigger.
4343

4444
When it references objects, the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] OLE Automation objects support traversing the referenced object to other objects that it contains. For example, when using the SQL-DMO **SQLServer** object, references can be made to databases and tables contained on that server.
4545

46-
## Related Content
47-
[Object Hierarchy Syntax (Transact-SQL)](../../relational-databases/system-stored-procedures/object-hierarchy-syntax-transact-sql.md)
48-
49-
[Surface Area Configuration](../../relational-databases/security/surface-area-configuration.md)
50-
51-
[Ole Automation Procedures Server Configuration Option](../../database-engine/configure-windows/ole-automation-procedures-server-configuration-option.md)
52-
53-
[sp_OACreate (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oacreate-transact-sql.md)
54-
55-
[sp_OAGetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oagetproperty-transact-sql.md)
56-
57-
[sp_OASetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oasetproperty-transact-sql.md)
58-
59-
[sp_OAMethod (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oamethod-transact-sql.md)
60-
61-
[sp_OAGetErrorInfo (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oageterrorinfo-transact-sql.md)
62-
63-
[sp_OADestroy (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oadestroy-transact-sql.md)
64-
65-
46+
## See also
47+
48+
- [Object Hierarchy Syntax (Transact-SQL)](../../relational-databases/system-stored-procedures/object-hierarchy-syntax-transact-sql.md)
49+
- [Surface Area Configuration](../../relational-databases/security/surface-area-configuration.md)
50+
- [sp_OACreate (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oacreate-transact-sql.md)
51+
- [sp_OAGetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oagetproperty-transact-sql.md)
52+
- [sp_OASetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oasetproperty-transact-sql.md)
53+
- [sp_OAMethod (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oamethod-transact-sql.md)
54+
- [sp_OAGetErrorInfo (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oageterrorinfo-transact-sql.md)
55+
- [sp_OADestroy (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oadestroy-transact-sql.md)
56+
57+
## Next steps
58+
59+
- [Ole Automation Procedures Server Configuration Option](../../database-engine/configure-windows/ole-automation-procedures-server-configuration-option.md)
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: "OLE Automation Result Sets | Microsoft Docs"
2+
title: "OLE Automation Result Sets"
33
description: Learn that if an OLE Automation property or method returns data in an array with one or two dimensions, the array is returned to the client as a result set.
44
ms.custom: ""
5-
ms.date: "03/14/2017"
5+
ms.date: "03/10/2022"
66
ms.prod: sql
77
ms.technology: stored-procedures
88
ms.reviewer: ""
@@ -14,20 +14,20 @@ helpviewer_keywords:
1414
- "result sets [SQL Server], OLE Automation"
1515
- "OLE Automation [SQL Server], result sets"
1616
- "arrays [SQL Server]"
17-
ms.assetid: b2f99e33-2303-427c-94b9-9d55f8e2a6ab
1817
author: WilliamDAssafMSFT
1918
ms.author: wiassaf
20-
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
19+
monikerRange: ">=sql-server-2016"
2120
---
2221
# OLE Automation Result Sets
23-
[!INCLUDE[SQL Server Azure SQL Database Synapse Analytics PDW ](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)]
22+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
23+
2424
If an OLE Automation property or method returns data in an array with one or two dimensions, the array is returned to the client as a result set:
2525

2626
- A one-dimensional array is returned to the client as a single-row result set with as many columns as there are elements in the array. For example, an array(10) is returned as a single row of 10 columns.
2727

2828
- A two-dimensional array is returned to the client as a result set with as many columns as there are elements in the first dimension of the array and with as many rows as there are elements in the second dimension of the array. For example, an array(2,3) is returned as 2 columns in 3 rows.
2929

30-
When a property return value or method return value is an array, sp_OAGetProperty or sp_OAMethod returns a result set to the client. (Method output parameters cannot be arrays.) These procedures scan all the data values in the array to determine the appropriate [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] data types and data lengths to use for each column in the result set. For a particular column, these procedures use the data type and length required to represent all data values in that column.
30+
When a property return value or method return value is an array, `sp_OAGetProperty` or `sp_OAMethod` returns a result set to the client. (Method output parameters cannot be arrays.) These procedures scan all the data values in the array to determine the appropriate [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] data types and data lengths to use for each column in the result set. For a particular column, these procedures use the data type and length required to represent all data values in that column.
3131

3232
When all data values in a column share the same data type, that data type is used for the whole column. When data values in a column are different data types, the data type of the whole column is chosen based on the following table. To use the following table, find one data type along the left row axis and a second data type along the top column axis. The intersection of the row and column describes the data type of the result set column.
3333

@@ -40,9 +40,12 @@ monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-s
4040
|**varchar**|**varchar**|**varchar**|**varchar**|**varchar**|**varchar**|**nvarchar**|
4141
|**nvarchar**|**nvarchar**|**nvarchar**|**nvarchar**|**nvarchar**|**nvarchar**|**nvarchar**|
4242

43-
## Related Content
44-
[OLE Automation Stored Procedures (Transact-SQL)](../../relational-databases/system-stored-procedures/ole-automation-stored-procedures-transact-sql.md)
45-
46-
[Ole Automation Procedures Server Configuration Option](../../database-engine/configure-windows/ole-automation-procedures-server-configuration-option.md)
43+
## See also
44+
45+
- [Ole Automation Procedures Server Configuration Option](../../database-engine/configure-windows/ole-automation-procedures-server-configuration-option.md)
46+
47+
## Next steps
48+
49+
- [OLE Automation Stored Procedures (Transact-SQL)](../../relational-databases/system-stored-procedures/ole-automation-stored-procedures-transact-sql.md)
4750

4851

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: "OLE automation return codes and error information | Microsoft Docs"
2+
title: "OLE automation return codes and error information"
33
description: Learn the details about OLE automation return codes and how to convert error code information.
44
ms.custom: ""
5-
ms.date: "03/08/2022"
5+
ms.date: "03/10/2022"
66
ms.prod: sql
77
ms.reviewer: ""
88
ms.technology: stored-procedures
@@ -11,14 +11,13 @@ helpviewer_keywords:
1111
- "return codes [SQL Server]"
1212
- "OLE Automation [SQL Server], return codes"
1313
- "OLE Automation [SQL Server], errors"
14-
ms.assetid: 9696fb05-e9e8-4836-b359-d4de0be0eeb2
1514
author: WilliamDAssafMSFT
1615
ms.author: wiassaf
17-
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
16+
monikerRange: ">=sql-server-2016"
1817
---
1918
# OLE automation return codes and error information
2019

21-
[!INCLUDE[SQL Server Azure SQL Database Synapse Analytics PDW ](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)]
20+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
2221

2322
The OLE automation system stored procedures return an **int** return code that is the HRESULT returned by the underlying OLE automation operation. An HRESULT of 0 indicates success. A nonzero HRESULT is an OLE error code of the hexadecimal form 0x800*nnnnn*, but when returned as an **int** value in a stored procedure return code, HRESULT has the form -214*nnnnnnn*.
2423

@@ -28,8 +27,8 @@ For example, passing an invalid object name (SQLDMO.Xyzzy) to sp_OACreate causes
2827

2928
You can use `CONVERT(binary(4), @hresult)` to convert an **int** HRESULT to a **binary** value.
3029

31-
For examples of supported conversion see [H. Using CONVERT with binary and character data](../../t-sql/functions/cast-and-convert-transact-sql.md#h-using-convert-with-binary-and-character-data).
30+
For examples of supported conversion, see [H. Using CONVERT with binary and character data](../../t-sql/functions/cast-and-convert-transact-sql.md#h-using-convert-with-binary-and-character-data).
3231

33-
## Related content
32+
## Next steps
3433

35-
[sp_OAGetErrorInfo (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oageterrorinfo-transact-sql.md)
34+
- [sp_OAGetErrorInfo (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oageterrorinfo-transact-sql.md)

docs/relational-databases/stored-procedures/ole-automation-sample-script.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
2-
title: "OLE Automation Sample Script | Microsoft Docs"
2+
title: "OLE Automation Sample Script"
33
description: Learn how to use an example of a Transact-SQL statement batch that uses the OLE Automation stored procedures to create and use an SQL-DMO SQLServer object.
44
ms.custom: ""
5-
ms.date: "03/14/2017"
5+
ms.date: "03/10/2022"
66
ms.prod: sql
77
ms.reviewer: ""
88
ms.technology: stored-procedures
99
ms.topic: conceptual
1010
helpviewer_keywords:
1111
- "OLE Automation [SQL Server], examples"
12-
ms.assetid: e59f75a9-ed41-4f12-888e-ffc57f9b3882
1312
author: WilliamDAssafMSFT
1413
ms.author: wiassaf
15-
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
14+
monikerRange: ">=sql-server-2016"
1615
---
1716
# OLE Automation Sample Script
18-
[!INCLUDE[SQL Server Azure SQL Database Synapse Analytics PDW ](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)]
19-
This topic contains an example of a [!INCLUDE[tsql](../../includes/tsql-md.md)] statement batch that uses the OLE Automation stored procedures to create and use an SQL-DMO SQLServer object in the local instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)]. Parts of the code are used as examples in the reference topics for the OLE Automation system stored procedures.
17+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
18+
19+
This article contains an example of a [!INCLUDE[tsql](../../includes/tsql-md.md)] statement batch that uses the OLE Automation stored procedures to create and use a SQL-DMO SQLServer object in the local instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)]. Parts of the code are used as examples in the reference articles for the OLE Automation system stored procedures.
2020

21-
```
21+
```sql
2222
USE AdventureWorks2012;
2323
GO
2424
DECLARE @Object int;
@@ -134,17 +134,11 @@ RETURN;
134134
GO
135135
```
136136

137-
## Related Content
138-
[OLE Automation Objects in Transact-SQL](../../relational-databases/stored-procedures/ole-automation-objects-in-transact-sql.md)
139-
140-
[sp_OACreate (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oacreate-transact-sql.md)
141-
142-
[sp_OAGetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oagetproperty-transact-sql.md)
143-
144-
[sp_OASetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oasetproperty-transact-sql.md)
145-
146-
[sp_OAMethod (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oamethod-transact-sql.md)
147-
148-
[sp_OADestroy (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oadestroy-transact-sql.md)
149-
150-
137+
## Next steps
138+
139+
- [OLE Automation Objects in Transact-SQL](../../relational-databases/stored-procedures/ole-automation-objects-in-transact-sql.md)
140+
- [sp_OACreate (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oacreate-transact-sql.md)
141+
- [sp_OAGetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oagetproperty-transact-sql.md)
142+
- [sp_OASetProperty (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oasetproperty-transact-sql.md)
143+
- [sp_OAMethod (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oamethod-transact-sql.md)
144+
- [sp_OADestroy (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oadestroy-transact-sql.md)

0 commit comments

Comments
 (0)