Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 2.16 KB

File metadata and controls

75 lines (53 loc) · 2.16 KB
title sp_OADestroy (Transact-SQL)
description sp_OADestroy destroys a created OLE object.
author markingmyname
ms.author maghan
ms.reviewer randolphwest
ms.date 06/23/2025
ms.service sql
ms.subservice system-objects
ms.topic reference
f1_keywords
sp_OADestroy_TSQL
sp_OADestroy
helpviewer_keywords
sp_OADestroy
dev_langs
TSQL

sp_OADestroy (Transact-SQL)

[!INCLUDE SQL Server]

Destroys a created OLE object.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

sp_OADestroy objecttoken
[ ; ]

Arguments

[!INCLUDE extended-stored-procedures]

objecttoken

The object token of an OLE object that was previously created by using sp_OACreate.

Return code values

0 (success) or a nonzero number (failure) that is the integer value of the HRESULT returned by the OLE Automation object.

For more information about HRESULT return codes, see OLE automation return codes and error information.

Remarks

If sp_OADestroy isn't called, the created OLE object is automatically destroyed at the end of the batch.

Permissions

Requires membership in the sysadmin fixed server role or execute permission directly on this stored procedure. The Ole Automation Procedures server configuration option must be enabled to use any system procedure related to OLE Automation.

Examples

The following example destroys the previously created SQLServer object.

EXECUTE
    @hr = sp_OADestroy
    @object;

IF @hr <> 0
BEGIN
    EXECUTE sp_OAGetErrorInfo @object;
    RETURN;
END

Related content