I have about 1.5 million files that I need to insert into the database. Each entry is inserted with a key that includes the file name.
Catch: Currently, files are not uniquely identified.
So what we would like to do for each file:
- Paste the entry. One of the fields in the record should include the Amazon key S3, which should include the identifier of the newly inserted record.
- Rename the file so that it includes an identifier so that it matches the key format.
The best I can do is:
- Run a separate insert command that returns the identifier of the added row.
- Add this back as a property to the individual business object that I am viewing.
- Generate an update statement that updates the S3 key to include the identifier
- Output the file, concatenate the identifier at the end of the file name.
How can I say it looks like this:
- 1.5 million insert statements
- individual execution of SqlCommand and reading, because we need an identifier),
- 1.5 million times sets the property of an object.
- 1.5 million update statements generated and executed
- Perhaps this could become one giant concatenated update statement to do everything at once; not sure if this helps
- 1.5 million copies of files.
I can't get around the actual part of the file, but for the rest, is there a better strategy that I don't see?
c # file sql-server insert sqlcommand
Seankilleen
source share