Stuck in the middle with you
You might be fortunate, and find that the interesting parts of your strings are at either end. However, chances are, you'll want to retrieve characters from somewhere around the middle. Let's see how to use RIGHT, LEN, CHARINDEX AND SUBSTRING to extract the interior portion of a text string. The description column can contain multiple reasons for power outages in each row. We want to extract any additional causes of outage whenever Weather appears in the description column.
This exercise is part of the course
Introduction to SQL Server
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Complete the query to find `Weather` within the description column
SELECT
description,
___('___', description)
FROM
grid
WHERE description LIKE '%Weather%';