I have a db where one column contains 2 pieces of data, e.g. first and last name.
The format is roughly ABC-1D23-4F34
I want to copy and insert the first 3 letters, the ABC, into a new column. Lets call these columns [full_id]
and [ref_id]
From reading it looks like substring is able to do this but I am doing something wrong here.
INSERT INTO [ref_id]
SUBSTRING([full_id], 1, 3)
FROM db.Name
Thank you for the help.
EDIT:
The update string worked. But I found that there are issues with my data and it is not all in proper formatting.
Is there a way to write a case where if the substring is not 3 letters it writes a null value?
Thanks again, and sorry for having bad data.