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

Update table based on values from a different table

Status
Not open for further replies.

utahjzz98

Programmer
Jan 9, 2003
69
US
I have a .csv file with several hundred million records that I have imported into a SQL Server table. In an attempt to normalize the data, I have created several sub tables that contain ID for several respective values contained in the main table. I am looking to update the values in the main table with their respective ID’s from the sub tables, but I am unsure of how to accomplish this.

As a small example of what I am trying to accomplish:
Table 1 contains FName, LName, Address, City, State, Zip, etc
Table 2 contains CityID, StateID, etc
I want to look for any value for City in Table 1 that equals 'Chicago', reference table 2 with the appropriate CityID for Chicago, and update Table1 with the matching CityID
 
I also want to add that I am aware of using Update [table name] Set [column name]=’[integer]’ where City = ‘chicago’, but due to the large number of rows, I don't want to have to manually update each ID separately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top