BUG: Inserting to a 255-byte String w/ Embedded quot

Last reviewed: April 8, 1997
Article ID: Q152620
The information in this article applies to:
  • Microsoft SQL Server, versions 4.21, 6.0 and 6.5
BUG# WINDOWS 15473 (4.21a, 6.00, 6.50) (sqlserver)

SYMPTOMS

When inserting into a char or varchar column and the embedded quote sequence (for example, two double quotation marks [""], or two single quotation marks['']) causes the string literal to exceed 255 bytes in length, SQL Server returns the following error message:

   Msg 260, Level 16, State 1
   Disallowed implicit conversion from datatype 'text' to datatype 'char'
   Table: 'pubs.dbo.tblQuotes', Column: 'strData'
   Use the CONVERT function to run this query.



CAUSE

SQL Server is checking the length of the string before resolving the multiple quote sequences. If the server resolved the ("") or ('') sequences before checking the length, the implicit conversion would not fail.

WORKAROUND

Use the CONVERT function to explicitly convert the value.

Here is an example of how to correct the first insert that fails:

use pubs go

drop table tblQuotes go

create table tblQuotes (

   strData     char(255)
)
go

insert into tblQuotes values("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""") go insert into tblQuotes values(CONVERT(VARCHAR(255),""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""")) go

select datalength(strData), strData from tblQuotes go

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 4.21a, 6.00, and 6.50. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words:
Keywords : kbbug6.50
Version : 4.21a 6.0 6.5
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.