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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query 1

Status
Not open for further replies.

Daveuk1

Technical User
Apr 12, 2005
7
GB
Im trying to update a table with the message line from another table but its not as straight as it may seem. Let me explain.

In my first table i have

Sequence Part1 Part2 Part3 LineText LabourCode
5 508 A 100 Brake Disc 508A100
5 WD1 B 050 Inspection WD1B050
4 357 A Wheel Hub 357A
2 06 Cooling System 06

etc

2nd Table

Dealerno ClaimNo LinkNo LabourCode Textline
99999 2222 1 0508A100000087 ?
55555 1111 1 0WD1B050000004 ?
99911 3333 2 0357A 54754257 ?
85811 8715 1 006 5554 ?

As you will see from the second table the Labour code relates to the labour code in the first table but with a 0 in front. What i want to do is where the labour code in my second table matches the labour code in my first table insert the line text that associated with it into the relevant record in the second table. Any help would be appreciated
 
Try this as a start:

Code:
UPDATE t2
SET textline = t1.linetext
FROM table2 t2
  JOIN table1 t1 ON t2.labourcode LIKE '0' + t1.labourcode + '%'

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top