Reputation: 3024
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!
Upvotes: 2
Views: 2985
Reputation: 263893
use UPDATE
statement
UPDATE tableName
SET UID = SUBSTRING(ProgUID,3,12)
Upvotes: 5
Reputation: 1899
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)
Upvotes: 2