SQLTeam.com | Weblogs | Forums

Transact SQL

sql2008r2

#1

I have the following script:

SELECT

Chgusr, chgdat,

RIGHT(zipcod, 5) FROM prvloc

How can I get it to show only zipcode +4 that ends with either 9999 or 9998


#2

Wouldn't you want LEFT rather than RIGHT?!

SELECT
    Chgusr, chgdat,
    LEFT(zipcod, 5)  AS zipcod
FROM prvloc
WHERE zipcod LIKE '%999[89]' AND LEN(zipcod) >= 9