Microsoft KB Archive/269884

= BUG: Invalid Style Parameter in CONVERT Function May Cause Access Violation =

Article ID: 269884

Article Last Modified on 9/4/2002

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q269884



BUG #: 57813 (SQLBUG_70)



SYMPTOMS
When an invalid style parameter value is used in a CONVERT function, SQL Server may generate an access violation (AV).



STATUS
Microsoft has confirmed this to be a problem in SQL Server 7.0.



MORE INFORMATION
The CONVERT function has the following syntax:

CONVERT (data_type[(length)], expression [, style])

For example, to return an date in 'mm/dd/yyyy' format, use a value of 101 for the style parameter: select convert(varchar(10), HireDate, 101) from employees If you run the following code in Query Analyzer: use northwind go select convert(varchar(10), HireDate, 'mm/dd/yyyy') from employees the following error is generated

ODBC: Msg 0, Level 19, State 1 SqlDumpExceptionHandler: Process 12 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

and the SQL Server errorlog may contain entries that resemble the following:

2001-05-04 09:22:50.84 spid7   Using 'sqlimage.dll' version '4.0.5' Stack Dump being sent to C:\MSSQL7\log\SQL00002.dmp 2001-05-04 09:22:56.03 spid7   Error: 0, Severity: 19, State: 0 2001-05-04 09:22:56.03 spid7   SqlDumpExceptionHandler: Process 7 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process. .
 * BEGIN STACK DUMP:
 * 05/04/01 09:22:56 spid 7
 * Exception Address = 00350030
 * Exception Code   = c0000005 E
 * Access Violation occurred writing address 00000001
 * Input Buffer 132 bytes -
 * s e l e c t  c o n v e r t ( v a r c h a r(10),   HireDate ,
 * ' m m / d d / y y y y ' )  f r o m   e m p l o y e e s
 * Input Buffer 132 bytes -
 * s e l e c t  c o n v e r t ( v a r c h a r(10),   HireDate ,
 * ' m m / d d / y y y y ' )  f r o m   e m p l o y e e s

--- Short Stack Dump 0x00350030 Module(UNKNOWN+0) --- 2001-05-04 09:22:56.63 spid7   Error: 0, Severity: 19, State: 0 2001-05-04 09:22:56.63 spid7   language_exec: Process 7 generated an access violation. SQL Server is terminating this process. For more information about the correct values to use with the style parameter, see &quot;CAST and CONVERT (T-SQL)&quot; in SQL Server Books Online.

Keywords: kbbug kbpending KB269884

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.