In SQL, how can I remove the first 4 characters of values of a specific column in a table? Column name is Student Code and an example value is ABCD123Stu1231.
I want to remove first 4 chars from my table for all records
Please guide me
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit:
To explain, RIGHT takes 2 arguments – the string (or column) to operate on, and the number of characters to return (starting at the “right” side of the string). LEN returns the length of the column data, and we subtract four so that our RIGHT function leaves the leftmost 4 characters “behind”.
Hope this makes sense.
Edit again – I just read Andrew’s response, and he may very well have interperpereted correctly, and I might be mistaken. If this is the case (and you want to UPDATE the table rather than just return doctored results), you can do this:
He’s on the right track, but his solution will keep the 4 characters at the start of the string, rather than discarding said 4 characters.