mike247
asked on
return data to left of dash excluding the dash
I have a database of inventory items that have prefixes based on manufacturers. We want to compile a list of these prefixes. I need to return only the data to the left of the first dash in the ItemNumber. There could be items with no dash. Any help you can provide is much appreciated. Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT LEFT(ItemNumber, CHARINDEX('-', ItemNumber + '-') - 1) AS TrimmedItemNumber
FROM ...
FROM ...
G'day Scott,
Yeah, was thinking of that except it would return the entire itemnumber when all we need is the Manufacturer code - which may not exist. So, thought it best not to return the entire itemnumber where there is no manufacturer code / prefix...
Seem to recall a similar question about prefixes but in a trigger from Mike...
Just a thought......
Cheers,
Mark
Yeah, was thinking of that except it would return the entire itemnumber when all we need is the Manufacturer code - which may not exist. So, thought it best not to return the entire itemnumber where there is no manufacturer code / prefix...
Seem to recall a similar question about prefixes but in a trigger from Mike...
Just a thought......
Cheers,
Mark
ASKER
Sorry, I thought I had closed this out the day the answer came in. I guess I didn't click through all the "next" buttons.
Open in new window
Some samples might make it easier :)