INF: SQL Server Truncation of a DBCS String

Last reviewed: April 9, 1997
Article ID: Q155723

The information in this article applies to:
  • Microsoft SQL Server, version 6.5

SUMMARY

If the data entered is too long for the specified datatype, char and varchar entries are truncated. If SQL Server is installed with appropriate DBCS as default code page and when this truncation happens right in the middle of a double-byte character, the whole double-byte character will be discarded.

The following scripts demonstrate this truncation.

CREATE TABLE test (

  col1 char (10),
  col1 varchar (10)
) GO

/* Let D represent a double character. */
/* Let L represent the leading byte.   */
/* Let T represent the trailing byte.  */
/* Let S represent a single character. */
/* Let s represent space (ASCII 20).   */


INSERT test VALUES ("SDDDDD", "SDDDDD") GO

SELECT * FROM test GO

col1       col2
---------- ---------- SLTLTLTLTs SLTLTLTLT

Because the truncated string is shorter than the maximum length, the char column that does not allow null value and the char variable will be padded with trailing blank while the varchar column will not store training blank.


Additional query words: DBCS
Keywords : kbprg SSrvProg
Version : 6.5.201 6.5.213
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 9, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.