Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

SET ANSI Command

Visual Studio .NET 2003

Determines how comparisons between strings of different lengths are made with the = operator in Visual FoxPro SQL commands.

SET ANSI ON | OFF

Parameters

ON
Pads the shorter string with the blanks needed to make it equal to the longer string's length. The two strings are then compared character for character for their entire lengths. Consider this comparison:
'Tommy' = 'Tom' 

The result is false (.F.) if SET ANSI is on because when padded, 'Tom' becomes 'Tom ' and the strings 'Tom ' and 'Tommy' don't match character for character.

The == operator uses this method for comparisons in Visual FoxPro SQL commands.

OFF
Specifies that the shorter string not be padded with blanks. The two strings are compared character for character until the end of the shorter string is reached. Consider this comparison:
'Tommy' = 'Tom'

The result is true (.T.) when SET ANSI is off because the comparison stops after 'Tom'.

Remarks

SET ANSI determines whether the shorter of two strings is padded with blanks when a SQL string comparison is made. SET ANSI has no effect on the == operator; when you use the == operator, the shorter string is always padded with blanks for the comparison.

SET ANSI is scoped to the current data session.

SET ANSI and the Query Designer   Visual FoxPro builds a SELECT - SQL command in the Query Designer when you create a query. When creating Join and Filter conditions, if you choose the Equal or Exactly Like options, the = or == operator is included in the generated SELECT. The SET ANSI setting can affect the results of queries you create and perform in the Query Designer.

String Order   In SQL commands, the left-to-right order of the two strings in a comparison is irrelevant — switching a string from one side of the = or == operator to the other doesn't affect the result of the comparison.

See Also

CREATE QUERY | MODIFY QUERY | SELECT – SQL | SET DATASESSION | SET EXACT

Show:
© 2014 Microsoft. All rights reserved.