INF: SQL Server Truncation of a DBCS String

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
Issue type :


Last Reviewed: April 1, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.