Char or Varchar? – You Decide (by John Koziol)

New to VFP 9 is behavior when a function is used in a SELECT statement that produces a character string. So, for example:

SELECT LEFT(name,10) FROM people

Prior to VFP 9, this would result in the character field “name“.  New to VFP 9 is storing the data to a Varchar field.

Admittedly, this could create some legacy issues, hence, the following new SET:  SET VARCHARMAPPING ON | OFF. If OFF, legacy behavior is unchanged.  When ON, expressions in a SELECT will yield varchar.


Comments (4)

  1. SteveC says:

    How does the VarChar type affect performance? I thought the fixed-length Char type was one of the reasons Rushmore was so fast.

  2. Just wondering. What would be faster: "set varcharmapping on" or a SQL – Select with the new cast() function. My guess is the former. Am I right?

  3. John Koziol says:

    First to Steve: Not sure although that makes for an interesting test scenario. I’ll look into it.

    Boudewijn: Looking things over, not much of a difference I would anticipate. However, I’ll investigate.

Skip to main content