Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 3.25 KB

File metadata and controls

47 lines (33 loc) · 3.25 KB
title Constructing an SQL Statement (ODBC) | Microsoft Docs
ms.custom
ms.date 03/14/2017
ms.prod sql
ms.prod_service database-engine, sql-database, sql-data-warehouse, pdw
ms.reviewer
ms.technology native-client
ms.topic reference
helpviewer_keywords
SQL Server Native Client ODBC driver, statements
statements [ODBC], constructing
ODBC applications, statements
ms.assetid 0acc71e2-8004-4dd8-8592-05c022bdd692
author markingmyname
ms.author maghan
monikerRange >=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current

Constructing an SQL Statement (ODBC)

[!INCLUDEappliesto-ss-asdb-asdw-pdw-md]

ODBC applications perform almost all of their database access by executing [!INCLUDEtsql] statements. The form of these statements depends on the application requirements. SQL statements can be constructed in the following ways:

  • Hard-coded

    Static statements performed by an application as a fixed task.

  • Constructed at run time

    SQL statements constructed at run time that enable the user to tailor the statement by using common clauses, such as SELECT, WHERE, and ORDER BY. This includes ad hoc queries entered by users.

The [!INCLUDEssNoVersion] Client ODBC driver parses SQL statements only for ODBC and ISO syntax not directly supported by the [!INCLUDEssDE], which the driver transforms into [!INCLUDEtsql]. All other SQL syntax is passed to the [!INCLUDEssDE] unchanged, where [!INCLUDEssNoVersion] will determine if it is valid [!INCLUDEssNoVersion]. This approach yields two benefits:

  • Reduced overhead

    Processing overhead for the driver is minimized because it only has to scan for a small set of ODBC and ISO clauses.

  • Flexibility

    Programmers can tailor the portability of their applications. To enhance portability against multiple databases, use primarily ODBC and ISO syntax. To use enhancements specific to [!INCLUDEssNoVersion], use the appropriate [!INCLUDEtsql] syntax. The [!INCLUDEssNoVersion] Native Client ODBC driver supports the complete [!INCLUDEtsql] syntax so ODBC-based applications can take advantage of all the features in [!INCLUDEssNoVersion].

The column list in a SELECT statement should contain only the columns required to perform the current task. Not only does this reduce the amount of data sent across the network, but also it reduces the effect of database changes on the application. If an application does not reference a column from a table, then the application is not affected by any changes made to that column.

See Also

Executing Queries (ODBC)