FIX: ODBC Functions TIMESTAMPADD and TIMESTAMPDIFF May Cause Error 128

Article translations Article translations
Article ID: 311000 - View products that this article applies to.
This article was previously published under Q311000
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 57464 (SQLBUG_70)
Expand all | Collapse all

Symptoms

If you use either of the ODBC canonical time functions TIMESTAMPADD or TIMESTAMPDIFF in a data modification query from an ODBC-based client application, the following error may occur which causes the SQL batch to fail to compile and execute:
Error 128, Level 15, State 1
The name 'SQL_TSI_YEAR' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.

Resolution

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
301511 INF: How to Obtain the Latest SQL Server 7.0 Service Pack
NOTE: The following hotfix was created prior to Microsoft SQL Server 7.0 Service Pack 4.

The English version of this fix should have the following file attributes or later:
   Date         Time    Version    Size        File name
   --------------------------------------------------------

   17-OCT-2001  18:49   7.00.1012  5,054,736   Sqlservr.exe
   14-JAN-2001  01:39   7.00.0978    586,000   Sqlsort.dll
				
NOTE: Because of file dependencies, the most recent hotfix or feature that contains the preceding files may also contain additional files.

Workaround

You can work around this problem in the following ways:
  • Use the native Transact SQL functions DATEADD and DATEDIFF instead of the ODBC canonical functions.
  • Use the ODBCCMPT utility to mark the ODBC application as being version 6.5 compliant.

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft SQL Server 7.0 Service Pack 4.

More information

The following values could occur as the column name reported in the error above:
  • SQL_TSI_YEAR
  • SQL_TSI_QUARTER
  • SQL_TSI_MONTH
  • SQL_TSI_WEEK
  • SQL_TSI_DAY
  • SQL_TSI_HOUR
  • SQL_TSI_MINUTE
  • SQL_TSI_SECOND
  • SQL_TSI_FRAC_SECOND
Here is an example query that uses an ODBC canonical function:
SELECT {fn TIMESTAMPDIFF(SQL_TSI_DAY,'2001-1-1', '2001-1-2')}
				
Normally, the ODBC driver for the data source you are connecting to translates the query, changing the ODBC canonical function into the native SQL language of the data source on the client during the process of submitting the query to the data source. However, with the SQL Server ODBC driver the ODBC canonical functions are not translated on the client and are instead evaluated on SQL Server itself.

Properties

Article ID: 311000 - Last Review: November 1, 2013 - Revision: 2.0
Applies to
  • Microsoft SQL Server 7.0 Standard Edition
Keywords: 
kbnosurvey kbarchive kbhotfixserver kbqfe kbbug kbfix kbsqlserv700presp4fix KB311000

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com