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.
Author |
Topic |
fast_parts2u
Starting Member
1 Post |
Posted - 2014-02-13 : 12:52:35
|
I have a table dbo.Sales that contains all sales records. There is a column in that table called ItemNumber that I'd like to match with ItemNumber in a flat file and update the ItemCost based on the ItemCost column in the flat file.So while there will be many sales records for each ItemNumber, I need to loop through and update the ItemCost in that sales record based on the corresponding ItemCost in the flat file. Does this make sense? I really need this for court and I can't figure out how to do it. I took a SQL course about 7 years ago but have forgotten everything.Database Name: BTDataDatabase Table: dbo.SalesDatabase Columns: ItemNumber (match on this), ItemCost (update this)FlatFile Name: InventoryCosts.txtFlatFile Columns: ItemNumber, ItemCostThere will be many sales records for each ItemNumber in the database table. I need to update each one with correct cost based on the item number and cost mapping from flat file.Please help. I will pay for someone to help me. I know this is very easy for skilled person and shouldn't take too long.thank you,John |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-02-17 : 07:41:59
|
you can use linked server or OPENROWSET for thisseeupdate tset col1 = srccol1,col2 = srccol2,..from table tjoin openrowset ('Microsoft.Jet.OLEDB.4.0', 'Text;Database=<foldername>',filename#txt) fon f.ItemNumber = t.ItemNumber ... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|