Article ID: 165433
Article Last Modified on 10/15/2002
APPLIES TO
- Microsoft Visual C++ 5.0 Enterprise Edition
This article was previously published under Q165433
SYMPTOMS
When you try to add a row to an SQL Server table using Query Designer you
receive the following error if one of the table's field names contains a
"-":
ODBC error: 37000 [Microsoft][SQL Server Driver]Line2: Incorrect syntax
near '-'
CAUSE
The data tool creates an SQL
INSERT statement that doesn't put quotes around field names. The generated
INSERT statement would look like:
INSERT INTO "x" (id, e-mail)
VALUES (1, 'name')
If data tools generated an
INSERT statement that used double quotes around the field name, then the
INSERT would work. The following syntax would work:
INSERT INTO "x" (id, "e-mail")
VALUES (1, 'name')
You can verify this by using the SQL Trace utility that ships with SQL
Server 6.5. You can use MS Query to test both
INSERT statements.
RESOLUTION
You can work around this problem in the following ways:
- Rename the field so that it doesn't contain a hyphen.
-or-
- Create the SQL INSERT statement manually. Click the SQL button on the Query toolbar after you open the table. Type and execute the correct INSERT statement. You need to retype the original SELECT query to see the updated contents of the table.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This problem was corrected in Visual C++
version 6.0 for Windows.
Additional query words: kbVC500bug kbVC600fix
Keywords: kbbug kbfix kbvc600fix kbeedition KB165433