There are several ODBC drivers available for Microsoft SQL Server, including:

  • SQL Server
  • SQL Server Native Client version
  • ODBC Driver version for SQL Server

where version is a version number (for example, ODBC Driver 17 for SQL Server). Which one you should use with Stonefield Query depends on a few things:

  • As of late 2019, the "ODBC Driver 17 for SQL Server" driver is the newest driver, so it may be the best one to use for your system. However, it doesn't work with SQL Server versions prior to 2008, so you may need to use an older driver in that case (the "ODBC Driver 11 for SQL Server" driver works with SQL Server 2005 and later). This driver isn't automatically installed with Windows, but it can be downloaded from

  • The "SQL Server" driver works with all SQL Server versions and comes installed with Windows. However, if you use this driver, Date fields are retrieved by Stonefield Query as character, so in that case, use the "ODBC Driver 17 for SQL Server" driver instead.

  • SQL Server Native Client is deprecated and Microsoft does not recommended it for new development work.

Regardless of which driver you use, VARCHAR(MAX) fields in SQL Server tables are read into Stonefield Query as empty strings. The only solution is to cast such fields to TEXT. To do that, in Studio select the field, choose the Calc page, turn off Stonefield Query expression, and enter CAST(table.field AS TEXT) for Output Expression, where table is the name of the table and field is the name of the field.

If you have a lot of fields to cast, you can automate that by creating a text file named SQConfig.sqs in your project folder with the following content:

lparameters tcMode, ;
  toDiscover, ;
if tcMode = 'BEFORESAVEFIELD' and ;
  toObject.cFieldType = 'M'
  toObject.cFieldExpr = 'cast(' + .cFieldName + ;
    ' as text)'

Now when you refresh the database, all VARCHAR(MAX) fields will be retrieved as memo fields.

© Stonefield Software Inc., 2023 • Updated: 10/29/19
Comment or report problem with topic