Insert With A Join?
Posted on 2013-01-30
I'm not sure how this might work, but I'm hoping it's possible...
I'm using VB.Net to read a file to pick up data to insert into a table. One of the values in the file is the store name which I need to cross reference to another table to get the store number. Now, I could (via VB code) use the store name to open the Store table and retrieve the store number which I can then put into the store ID field in the data table I'm inserting into, but I'm hoping that I can do it in one shot with an INSERT query.
The table I'm INSERTing into is "DataTable" and contains the fields "StoreID", "Manager", "SalesDate", and "SalesAmount"
The cross reference table is "Stores" and contains the fields "StoreID" and "StoreName".
The file I'm reading would contain what will be he fields of "StoreName", "Manager", "SalesDate", and "SalesAmount".
Is this possible, and how might I do it?