BUG: Changed Locale Settings in Extended Stored Procedure May Cause Incorrect Results (246199)
The information in this article applies to:
- Microsoft SQL Server 6.5
- Microsoft SQL Server 7.0
This article was previously published under Q246199
BUG #: 18859 (SQLBUG_65)
BUG #: 56451 (SQLBUG_70)
BUG #: 213085 (SHILOH)
SYMPTOMS
Any code that changes the locale settings and that runs in an extended stored procedure, may cause SQL Server to interpret numbers incorrectly.
The symptoms may vary widely depending on the exact circumstances but do include the following:
This problem may occur if both of the following conditions are true:
- SQL Server calls an extended stored procedure that changes the locale settings. For example, using xp_startmail with the Outlook Address Book.
-and- - SQL Server uses the conversion routines of the Msvcrt.dll file.
NOTE: For SQL Server 6.5, this means SQL Server uses the Msvcrt40.dll file version 4.20.6172 (this file is installed by Microsoft Windows NT 4.0 into the System32 directory), because this version of Msvcrt40.dll is a "wrapper DLL" and forwards all conversions to the Msvcrt.dll file.
CAUSE
Locale settings are process-wide. These settings are used by SQL Server to convert strings (such as literals in Transact-SQL statements) to numbers.
Every Win32 process is initialized with the ANSI-C settings; these are the correct settings for interpreting numbers in Transact-SQL statements. For example, the decimal separator is point ("."), and so on.
Any changes to the locale settings of an extended stored procedure affect the way SQL Server converts strings to numbers. For example, an extended stored procedure calling "setlocale(LC_ALL, "")" sets the locale setting to the regional settings of the process owner, and thus exhibits this problem.
WORKAROUND
If this problem happens with an extended stored procedure and you own the source code, you can avoid changing the locale settings within your code. If that is not possible, you can reset the locale settings to ANSI-C before you return from your extended stored procedure. For example, by calling "setlocale( LC_ALL, "C" );".
In the scenario described in the "More Information" section, suppose the following:
- SQL Server runs under a Windows NT account with non-SQL regional settings (for example, "German (Standard)").
- SQLMail is enabled.
- The MAPI profile used by SQLMail contains the Outlook Address Book service.
- On SQL Server 6.5 only: SQL Server uses Msvcrt40.dll version 4.20.6172.
In this scenario, the possible workarounds are:
- Remove the Outlook Address Book service from the MAPI profile used by SQLMail.
-or- - Run SQL Server under a Windows NT account with regional settings compatible to SQL Server (for example, "English (United States)").
-or- - For SQL Server 6.5 only: Make sure that SQL Server uses a Msvcrt40.dll file newer than version 4.20.6172, having a file size > 300 kilobytes.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 10/17/2003 |
---|
Keywords: | kbBug kbpending KB246199 |
---|
|