PRSQL9103048: Using the Datalength() Function with Convert()

ID Number: Q70868

1.10

OS/2

buglist1.10

Summary:

PROBLEM ID: PRSQL9103048

SYMPTOMS

Using the Datalength() function in conjunction with the convert()

function will return incorrect results if the convert() function

uses the CHAR datatype in a local variable (@var1,@var2).

CAUSE

The Datalength() function will return the combined length of the

variables, instead of the length of the datatype converted to.

For example, if @var1 is defined as 10 characters and @var2 is

defined as 7 characters, the following statement will return a

length of 17:

Datalength(convert(char(15),@var1 + @var2))

STATUS

Microsoft has confirmed this to be a problem in SQL Server version

1.10. We are researching this problem and will post new information

here as it becomes available.