2
  • I am not very good with SQL and would like to be able to become better.

  • I am having some trouble trying to preform a certain table manipulation.

  • I would like to be able to select the substring out of the ProgUID column below

something like...

SUBSTRING(table.ProgUID,3,12);

which would give me CAMVE-9701 for the ProgUID P-CAMVE-9701-1 (removing the P- from the beginning and the -1 from the end), and then insert the substring into that rows UID.

I assume this should be fairly easy, and I have been trying to figure it out but havent had much luck.

If there is a better approach please let me know!

Thanks in advance for your thoughts / help!

enter image description here

2 Answers 2

5

use UPDATE statement

UPDATE tableName
   SET UID = SUBSTRING(ProgUID,3,12)
Sign up to request clarification or add additional context in comments.

Comments

2

If the portion you want is always 12 characters, then

UPDATE table
SET UID = SUBSTRING(ProgUID, 3, 12)

otherwise

UPDATE table
SET UID = SUBSTRING(ProgUID, 3, LENGTH(ProgUID)-2)

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.