1
Answer

sqlbulkcopy and column maping class C#

j c

j c

10y
714
1
I have metadata table that contain source columns/tables and destination columns
and tables information and their column mapping information

SourceTable
SourceTableID SourceTableName
1                      ProductA
2                      ProductB

3   ProductC
SourceTableColumnn table
SourceTableColumnID SourceTableID SourceTableColumnName
1                                     1                              Name
2                                     1                              Color
3                                     1                              Size
4                                     2                              Quality
5                                     3                               Quantity

 DestinationTable
DestinationTableID  DestinationTableName
1                                ProductA
2                                ProductB
3                                ProductC

DestinationTableColumnn table
DestinationTableColumnID DestinationTableID DestinationTableColumnName
1                                                1                               Name
2                                                1                               Color

3                                                1                               Size
4                                                2                               Quality
5                                                3                               Quantity

And
SourcDestinationColumnMapping  Table
SourceTableColumnID    DestinationTableColumnID
1                                         1
2                                         2
3                                         3
4                                         4
5                                         5

I would like to dynamically ( setting data connection and mapping the column / table )  load data from source to destination table based on
this metadata table using sqlbulkcopy and columnmaping class (C#) since there
will be many tables and each table will have different columns.
How can I do this in C#? can you show me some examples?

Thanks


 
Answers (1)