Select first token of value

I have a column that holds values like this: OPBM-20, OBMM-10, OPMD-30, etc.

Is there a way to do a SELECT that only selects the portion before the hyphen? I need something like ListFirst or GetToken, but I can’t seem to find anything in SQL that does this.

depends

once again, you neglected to mention which database system you’re using :smiley:

Doh! Currently Access but soon-to-be MSSQL 2008.

Oh and I can’t do LEFT(column,4) because sometimes there are 3 characters before the hyphen, and sometimes there are 4.

solutions will be similar but different

use a function to find the string position of the dash (msaccess: InStr, sqlserver: CharIndex)

then embed this inside a substring function… SUBSTRING(mycolumn FROM 1 TO position - 1)

I’ll give that a shot, thanks!