Board index » delphi » MSSQL 2000 / fun : Upper(), Size Mismatch for field!

MSSQL 2000 / fun : Upper(), Size Mismatch for field!

I have a delphi 4 application which works on MS SQL 7, Now i started using
MS SQL 2000 instead of SQL 7

My application works fine on SQL 7, if the same database i restore on SQL
2000 and run my application,
At time of load, it gives me this error "Size mismatch for field 'Name'
expecting 44 actual 64'

My query is

Select (UPPER(P.LastName) + ", " +  P.FirstName  +" "+ P.MiddleInitial) as
Name
From patient P where P.Patienkey = :iPatientkey;

My actual database field length for Lastname,firstname is 20 each and
middleinitial = 1 so total size
20 + 2(", ") + 20 + 1(" ") + 1 = 44.

I have NAME field set as a TStringField on the query, and it shows as size =
44 when i am connected to sql 7, now if i connect to sql 2000, then even at
design time if i activate the query (active = true), it gives the same error
expected 44 actual 64. It adds up size by  20 for the function UPPER ?????

If i remove function UPPER and run under SQL 2000, no problems, it runs with
the actual size of 44 (both design and run time).

Is it delphi bde or ms sql 2000, who is adding this extra 20 to the size. Is
this a bug ??

Please Help !!!

Darshak Shah

 

Re:MSSQL 2000 / fun : Upper(), Size Mismatch for field!


Try trim(), if that doesn't work, check to see if both fields are varchar()
or char(). Nvarchar() can wreak havoc with string lengths.

Something like this>>
UPPER(Trim(P.LastName) + ", " + Trim( P.FirstName)  +" "+
Trim(P.MiddleInitial) as
Name

Quote
"Darshak Shah" <dars...@mdbase.com> wrote in message

news:3a412654_1@dnews...
Quote
> I have a delphi 4 application which works on MS SQL 7, Now i started using
> MS SQL 2000 instead of SQL 7

> My application works fine on SQL 7, if the same database i restore on SQL
> 2000 and run my application,
> At time of load, it gives me this error "Size mismatch for field 'Name'
> expecting 44 actual 64'

> My query is

> Select (UPPER(P.LastName) + ", " +  P.FirstName  +" "+ P.MiddleInitial) as
> Name
> From patient P where P.Patienkey = :iPatientkey;

> My actual database field length for Lastname,firstname is 20 each and
> middleinitial = 1 so total size
> 20 + 2(", ") + 20 + 1(" ") + 1 = 44.

> I have NAME field set as a TStringField on the query, and it shows as size
=
> 44 when i am connected to sql 7, now if i connect to sql 2000, then even
at
> design time if i activate the query (active = true), it gives the same
error
> expected 44 actual 64. It adds up size by  20 for the function UPPER ?????

> If i remove function UPPER and run under SQL 2000, no problems, it runs
with
> the actual size of 44 (both design and run time).

> Is it delphi bde or ms sql 2000, who is adding this extra 20 to the size.
Is
> this a bug ??

> Please Help !!!

> Darshak Shah

Other Threads