select * from "authors" where "au_lname" = 'White'
With this option enabled, it is not legal to enclose the character string 'White' in double quotation marks. ANSI SQL interprets "White" as an identifier, not a character string.
According to ANSI SQL, when a character string includes a single quotation mark or an apostrophe, it should be represented by two single quotes, as in the following example:
select * from authors where au_lname = 'O''Brien'
This means that applications must parse character strings for single quotation marks before building the strings into SQL commands, and add a second single quotation mark.
ODBC can be used in a way that eliminates the need to first parse character strings for single quotation marks. When an ODBC application uses SQLBindParameter() to bind character program variables to parameter markers in SQL commands, the character strings are not enclosed in either single or double quotation marks. There is no need for the application to have to parse the strings for single quotation marks. The following is an example:
SDWORD pcbVal1 = SQL_NTS;
(UCHAR *)"select * from authors where au_lname = ?", SQL_NTS);
Note that while the strcpy command contains the string "O'Brien," C only puts the characters O'Brien in the variable szCol1. The double quotation marks in this case are the string delimiters for C, and have nothing to do with SQL.
The SQL Server ODBC driver and Microsoft OLE DB Provider for SQL Server automatically set QUOTED_IDENTIFIER to ON when connecting. This can be configured in ODBC data sources, in ODBC connection attributes, or in OLE DB connection properties. SET QUOTED_IDENTIFIER defaults to OFF for connections from B-Library applications.
Id. de artículo: 156501 - Última revisión: 07/10/2008 - Revisión: 1