Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Matching an ID key to a table based on row values

Author  Topic 

tomsharp85
Starting Member

2 Posts

Posted - 2015-04-02 : 17:57:22

Hi all, if I have tables in my database, tblNames1, tblNames2, tblNames3 for ex, and for addresses tblAddresses, can I match the address IDs in the names tables to the address table based on the values of a field? In this case CompanyName. Can they be matched automatically? My issue is that I have a huge CSV file with all the address information that needs to be assigned a foreign key based on the company name field which is also present in all the names tables, thankfully all the names are normalized... Does anybody know how I could acheive this..?

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-04-03 : 16:14:24
So, do you mean that tblNames1, ... etc. have a column called CompanyName and so does tblAddress? If so, this is a simple join on that column. IF not, perhaps you could post:

1. CREATE TABLE statements for all tables involved
2. INSERT INTO statements to add some test data to the tables
3. Desired result from your query using the data from item 2.
Go to Top of Page
   

- Advertisement -