Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update based on two tables

Status
Not open for further replies.

togatown

Technical User
Jun 23, 2003
65
US
Well, I know this doesn't work........any help appreciated.

UPDATE CustomerExt SET FirstName2 =
(SELECT LTRIM(RIGHT(Customer.FirstName, LEN(Customer.FirstName)-(PATINDEX('%&%', Customer.FirstName))))
FROM Customer
LEFT JOIN CustomerExt ON Customer.ID = CustomerExt.ID
WHERE FirstName LIKE '%&%')
 
Looks like a parenthesis issue. Try this...

Code:
UPDATE CustomerExt SET FirstName2 = 
(SELECT LTRIM(RIGHT(Customer.FirstName, LEN(Customer.FirstName)-(PATINDEX('%&%', Customer.FirstName)))))
FROM Customer
LEFT JOIN CustomerExt ON Customer.ID = CustomerExt.ID
WHERE FirstName LIKE '%&%'

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks George, worked like a charm. There were 4200+ of these, didn't want to do it manually. Now if I can teach people not to enter the data incorrectly.......... ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top