?
Solved

SQL 2005 Update Query

Posted on 2007-10-21
2
Medium Priority
?
2,810 Views
Last Modified: 2009-11-20
OK you T SQL query experts try this one out;
I  have two tables;
1. "Vendors", containing 200 unique Vendors names [ varchar(30)] and matching Expense Codes [int(2)], 2. "Transactions", containing 20,000 transaction Descriptions [varchar(200)] , ExpenseCodes [int(2)] and $ Values.
A one-to-many relationship exists between Vendors and Transactions and a vendor's name may be located anywhere in the Description field of the "Transactions" table.
I want to update the ExpenseCode field in "Transactions" from the Expense Code data recorded in "Vendors" based on a match of the vendor's name anywhere in the Description feild of the "Transactions" table.
Full Text Indexing is enabled on the Transactions table.

 
0
Comment
Question by:FillSee
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 20117676
this should do:

UPDATE transaction
   set ExpenseCode = v.ExpenseCode
FROM transaction t
JOIN vendors v
  on t.description like '%' + v.names + '%'
 
0
 

Author Comment

by:FillSee
ID: 20120565
Fantastic, thanks angelII.  It worked perfectly. Solution accepted first go!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question