DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 155723 - Last Review: January 16, 2015 - Revision: 3.3

This article was previously published under Q155723
This article has been archived. It is offered "as is" and will no longer be updated.

SUMMARY

If dual byte character set (DBCS) data is too long to fit into a char or varchar column, the data is truncated to fit into the column. If Microsoft SQL Server uses a DBCS code page and this truncation happens right in the middle of a double-byte character, the whole double-byte character is discarded.

The following scripts demonstrate this truncation. It is assumed that the code page that applies here is a DBCS code page.
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 a null value and the char variable is padded with trailing blanks while the varchar column will not store trailing blanks.

APPLIES TO
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 6.5 Standard Edition
  • Microsoft SQL Server 2000 Standard Edition
Keywords: 
kbnosurvey kbarchive kbinfo kbprogramming KB155723
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support