PRSQL9202008: Convert Defaults to 30 When No Length Is Given

ID Number: Q80640

1.11 4.20

OS/2

buglist1.11 buglist4.20

Summary:

Problem ID: PRSQL9202008

SYMPTOMS

A statement of the form

select convert(char, <column>) from <table>,

where <column> is a char, varchar, or text column in <table>,

returns the first 30 characters of <column>. Page 43 of the

"Microsoft SQL Server Language Reference" for version 1.11

is somewhat misleading when it states:

If no length is specified when converting to char, varchar,

binary or varbinary datatypes, the data adapts to any size

necessary.

That is, if <column> is of type char(100), the above text implies

that the above SELECT statement must return all the characters in

<column>.

This behavior also occurs when conversion is done to varchar.

CAUSE

The value of 30 is incorrectly hard coded as the default when no

length is specified as the default.

STATUS

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

1.11 and 4.2. We are researching this problem and will post new

information here as it becomes available.

Additional reference words: 1.11 4.20