Link to home
Start Free TrialLog in
Avatar of isaacr25
isaacr25

asked on

Query for stripping first 5 characters

I need to run a query on a database table (let's call it TABLE1) to KEEP the LAST 4 characters for all values in the SSN field. How do I do this? Thanks.

Database: SQL Server 2000
Avatar of chapmandew
chapmandew
Flag of United States of America image

select last4 = right(ssn, 4)
from table1
Avatar of isaacr25
isaacr25

ASKER

This is a select query. Will this actually remove the preceding characters, leaving 4 characters?
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
a typo from chapmandew's post

update t1
set ssnfield = right(ssnfield, 4)
from table1 t1

or

update table1
set ssnfield = right(ssnfield, 4)
yep, good catch...forgot my alias.