We help IT Professionals succeed at work.

Extract substring from field in SQL

138 Views
Last Modified: 2015-10-20
Using a SELECT query if possible, I need to "extract" a substring from within a field from a SQL db table. For example, I have a summary field in the 'Service' table [dbo.Service.summary] that contains a lot of unnecessary data but somewhere in all of that data is a substring that begins with 'INC' such as 'INC1256559'. How do I select only the substring (beginning with 'INC' and ending with the following space minus 1 [' ' -1]? Of course, I want to give the resulting column an alias like AS 'INC Number'


Full Example: T0554 Incident INC1256559 - DSL possible damaged cable run need tech to replace patch and phone cable
Comment
Watch Question

Lead Software Engineer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.