Question

I was wondering if there was a way to qualify the table mappings when using sqlbulkcopy in c#?

Currently, I have a table that contains Stock Codes and then columns associated with range of weekly bucks.

example:

Stock Code | 11-2013 | 12-2013| 13-2013 | 14-2013 etc etc.

I have a query that returns quantities for the given stock code and the week number in which they occurred.

example:

part a | 20 | 11-2013

part b | 10 | 14-2013

Ideally, there would be a way to set the columnmappings.add method and specify that I would like to map the date column of the table to the resulting date in the return row of the query. I would show what I have; however, I have no idea if this is even possible. Any suggestions or alternative ideas would be great.

Thanks

Was it helpful?

Solution

Not directly possible. Your source data has to match to your destination data. The SqlBulkCopy class isn't going to do that for you.

Create a sql query from your source data that matches the table schema of your destination table. Then you can use the SqlBulkCopy class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top