I developed an automation application of a car service. I started accessories module yet but i cant imagine how should I build the datamodel schema.
I’ve got data of accessories in a text file, line by line (not a cvs or ext.., Because of that, i split theme by substring). Every month, the factory send the data file to the service. It includes the prices, the names, the codes and etc. Every month the prices are updated. I thought the bulkinsert (and i did) was a good choice to take the data to SQL, but it’s not a solution to my problem. I dont want duplicate data just for having the new prices. I thought to insert only the prices to another table and build a relation between the Accessories – AccesoriesPrices but sometimes, some new accessories can be added to the list, so i have to check every line of Accessories table. And, the other side, i have to keep the quantity of the accessories, the invoices, etc.
By the way, they send 70,000 lines every month. So, anyone can help me? 🙂
Thanks.
70,000 lines is not a large file. You’ll have to parse this file yourself and issue ordinary
insertandupdatestatements based upon the data contained therein. There’s no need for using bulk operations for data of this size.The most common approach to something like this would be to write a simple SQL statement that accepts all of the parameters, then does something like this:
(Alternatively, you could try rewriting this statement to use the
mergeT-SQL statement)Where…
<exists condition>represents whatever you would need to check to see if the item already exists<new values>is the set ofColumn = valuestatements for the columns you want to update<columns>is the set of columns to insert data into for new items<values>is the set of values that corresponds to the previous list of columnsYou would then loop over each line in your file, parsing the data into parameter values, then running the above SQL statement using those parameters.