I have some data that I needs to be searched for the comma character.
example entry I need to locate in the field Cita开发者_Go百科tion in the Citations table: This is sometimes true, Textual Reference
In the end, I'm looking to extract Textual Reference
Selecting the column with the data:
select Citation from Citations;
Try something like this:
SELECT Citation
, SUBSTRING(Citation, CHARINDEX(',', Citation) + 1,
LEN(Citation) - CHARINDEX(',', Citation))
FROM Citations
WHERE (Citation LIKE '%\,%' ESCAPE '\')
ORDER BY Citation
This works to select the data, but doesn't isolate what I want:
SELECT Citation
FROM Citations
WHERE (Citation LIKE '%\,%' ESCAPE '\')
ORDER BY Citation
Ah, this works:
SELECT Citation,
SUBSTRING(Citation,
CHARINDEX(',', Citation) + 1,
LEN(Citation) - CHARINDEX(',', Citation)) AS Truncated
FROM Citations
WHERE (Citation LIKE '%\,%' ESCAPE '\')
ORDER BY Truncated
Thanks ck!
精彩评论