cydewaze — 2013-04-19T13:26:59-04:00 — #1
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.
r937 — 2013-04-19T14:08:35-04:00 — #2
once again, you neglected to mention which database system you're using
cydewaze — 2013-04-19T14:39:39-04:00 — #3
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.
r937 — 2013-04-19T14:56:09-04:00 — #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)
cydewaze — 2013-04-19T15:31:49-04:00 — #5
I'll give that a shot, thanks!
system — 2014-10-08T00:06:11-04:00 — #6
This topic is now closed. New replies are no longer allowed.