The "Incorrect syntax..." error occurs when you use the Microsoft SQL Server ODBC driver


When you use SAS/ACCESS® Interface to Microsoft SQL Server against tables with reserved names such as GROUP or ORDER, the following error can occur:

ERROR: Error attempting to CREATE a DBMS table. ERROR: CLI execute error: [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Incorrect syntax near the keyword 'group'.
   

The keyword in the error message varies depending on the reserved name of the table. The problem does not happen with SAS/ACCESS® Interface to ODBC.

Here is example code that can cause the error:

libname test2 sqlsvr dsn=data-source-name;

proc sql;
select * from test2.group;
quit;

 

The problem occurs because the ODBC driver by default does not use quoting for table names. To circumvent the problem, do one of the following:

Advanced tab with red highlight around the checkmarked box for "Enable Quoted Identifiers"