ערוך

שתף באמצעות


sp_OADestroy (Transact-SQL)

Applies to: SQL Server

Destroys a created OLE object.

Transact-SQL syntax conventions

Syntax

sp_OADestroy objecttoken
[ ; ]

Arguments

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.

EXEC @hr = sp_OADestroy @object;

IF @hr <> 0
BEGIN
    EXEC sp_OAGetErrorInfo @object;

    RETURN
END;