خرید بک لینک

Vote count: 0

I'm trying to extract specific parts of a string, that could be any anywhere within the string.

07-16 ACADIA/07-10 OUTLOOK/08-16 ENCLAVE/09-16 TRAVERSE FLOORLINER

For example, here's a description with multiple ranges of years. I need to extract 07-16, 07-10, 08-16, and 09-16. I have code to extract 07-16, but i'm starting to get lost in the code at this point trying to figure out how to extract them. I also need to get the model to compare with the model in our database, but a lot of the descriptions have small inconsistencies in them

for example: Ford F-150, F-250... Ford F 150, F 250.. Ford F150, F250.. etc.

F-150 would be the correct value stored in the database to compare with.

This is the code I've used so far to pull the first year range

DECLARE @TABLE AS TABLE (DESCRIPTION VARCHAR(101))

INSERT INTO @table VALUES ('07-16 ACADIA/07-10 OUTLOOK/08-16 ENCLAVE/09-16 TRAVERSE FLOORLINER')

SELECT Left(
                     SubString(DESCRIPTION, PatIndex('%[0-9.-]%', DESCRIPTION), 5),
                     PatIndex('%[^0-9.-]%', SubString(DESCRIPTION, PatIndex('%[0-9.-]%', DESCRIPTION), 5) + 'X')-1)
FROM    @TABLE

asked 31 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 19 مرداد 1395 ساعت: 23:14

صفحه بندی