0

There is a column that has value XYZ|YYYY-MM-DD and I have to extract this XYZ from that column.

XYZ has a different value for each row.

3
  • Please, show your current code and describe, what is the issue with it. If you have any errors, post them as plain text. Commented Jun 24, 2021 at 17:08
  • Sql Server 2008 has been end of life for a couple years now. That means no more patches... not even critical security updates. It's dangerous and irresponsible to still be using it. Commented Jun 24, 2021 at 17:08
  • Is XYZ a placeholder for n characters or is it always 3 characters? Commented Jun 24, 2021 at 17:09

1 Answer 1

2

It looks like you just want the first substring before the pipe character. If so, then just use a basic substring operation:

SELECT SUBSTRING(col, 1, CHARINDEX('|', col) - 1)
FROM yourTable;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.