- Thread starter 7cent
- Start date

So In other words, the value in column A is 123456789 you need a script that will put 456789 in another column in the same row? This sounds like SQL homework as I can't think of a practical use for such a thing except perhaps stripping area codes from phone numbers.

Yes, exactly.. What I am doing is trying to link my part numbers with another companies part numbers. In their system they give a vendor indicator in the beginning of the actual part number. My data has a column for the vendor, and then the part number..

unfortunately it is not as easy as taking right(number,7) because the part numbers will range from 2 to 5 digits.. The phone number example is easy because that is constant.

Thanks... I will probaby have some more, because that is 1 out of 50 vendors.. Ahh, it's going to be a great weekend..

thanks again.

You're going to want to use the char_length expression to determine the number of characters, then subtract 3, then take the right() of that value

RIGHT(expression,(CHAR_LENGTH(expression)-3))

RIGHT(expression,(CHAR_LENGTH(expression)-3))

Code:

```
Server: Msg 536, Level 16, State 1, Line 1
Invalid length parameter passed to the substring function.
The statement has been terminated.
```

close... length didn't work but LEN did.. then I got this error

What version of SQL anyway?? 7? 2005?