FIX: UPPER and LOWER Functions Return Metadata Length as if DBCS Were Used (290921)
The information in this article applies to:
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q290921
BUG #: 351791 (SHILOH_bugs)
SYMPTOMS
When the UPPER or LOWER function is used on a column, the result set will have metadata that is twice the length of the string. This is the expected behavior on a double-byte character set (DBCS) collation, which could potentially have 2 bytes per character and where the number of bytes for a character could change based on the case. However, it is not expected behavior for single-byte character set (SBCS) collations.
CAUSE
The UPPER and LOWER functions assume that the number of bytes in the result set could always be twice the number of characters, even in an SBCS environment.
RESOLUTIONTo resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the
Microsoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack
WORKAROUND
Use the CAST or CONVERT functions to result in the corrent metadata length; for example:
use pubs
go
select CAST(LOWER('abc') as char(3)) as COL1 into meta
select COL_LENGTH('meta', 'COL1') as 'Column Length'
--COL_LENGTH returns a value of 3.
--Without the CAST function, 6 would be returned instead.
go
drop table meta
STATUSMicrosoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.
Modification Type: | Major | Last Reviewed: | 11/6/2003 |
---|
Keywords: | kbBug kbfix kbSQLServ2000sp1fix KB290921 |
---|
|