Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 2.35 KB

File metadata and controls

57 lines (41 loc) · 2.35 KB
title Command syntax (OLE DB driver)
description Learn about command syntax that the OLE DB Driver for SQL Server recognizes and how to run a SQL Server stored procedure.
author David-Engel
ms.author davidengel
ms.date 04/20/2021
ms.service sql
ms.subservice connectivity
ms.topic reference
ms.custom
ignite-2025
helpviewer_keywords
OLE DB Driver for SQL Server, commands
commands [OLE DB]
OLE DB Driver for SQL Server, stored procedures
stored procedures [OLE DB], command syntax

Command Syntax

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics PDW FabricSQLDB]

[!INCLUDEDriver_OLEDB_Download]

The OLE DB Driver for SQL Server recognizes command syntax specified by the DBGUID_SQL macro. For the OLE DB Driver for SQL Server, the specifier indicates that an amalgam of ODBC SQL, ISO, and [!INCLUDEtsql] is valid syntax. For example, the following SQL statement uses an ODBC SQL escape sequence to specify the LCASE string function:

SELECT customerid={fn LCASE(CustomerID)} FROM Customers

LCASE returns a character string, converting all uppercase characters to their lowercase equivalents. The ISO string function LOWER does the same operation, so the following SQL statement is an ISO equivalent to the ODBC statement above:

SELECT customerid=LOWER(CustomerID) FROM Customers

The OLE DB Driver for SQL Server processes either form of the statement successfully when specified as text for a command.

Stored Procedures

When executing a [!INCLUDEssNoVersion] stored procedure using an OLE DB Driver for SQL Server command, use the ODBC CALL escape sequence in the command text. The OLE DB Driver for SQL Server then uses the remote procedure call mechanism of [!INCLUDEssNoVersion] to optimize command processing. For example, the following ODBC SQL statement is preferred command text over the [!INCLUDEtsql] form:

  • ODBC SQL

    {call SalesByCategory('Produce', '1995')}
  • Transact-SQL

    EXECUTE SalesByCategory 'Produce', '1995'

See Also

Commands