How do I use the 'Substring' function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

SELECT COLUMN_1, SUBSTR(COLUMN_1, 1, 3)
FROM TABLE_NAME;

COLUMN_1 SUBSTR(COLUMN_1, 1, 3)
======= =================
ABCDEF ABC

I'm trying to retrieve just the first 3 characters of a string variable
and ACCESS doesn't like the 'substr' function...
 
Check out Left Function, Right Function, and Mid Function in the help files.
I believe the Mid function is probably the closest equivalent to SUBSTR.
 
SELECT COLUMN_1, SUBSTR(COLUMN_1, 1, 3)
FROM TABLE_NAME;

COLUMN_1 SUBSTR(COLUMN_1, 1, 3)
======= =================
ABCDEF ABC

I'm trying to retrieve just the first 3 characters of a string variable
and ACCESS doesn't like the 'substr' function...

ACCESS SQL and SQL/Server T-SQL are *two different dialects*; in
particular, the custom functions are different.

The Access/JET substring function is named Mid(). See also Left() and
Right() in the VBA help.


John W. Vinson[MVP]
 
Back
Top