I want to use SqlBulkCopy C# to insert rows to Sql DataBase but I don't understand if I define a table in the Db with X columns and I want to insert 2 DataTables- one of them contains only y/x columns and the second contains only z/x columns. when I use SqlBulkCopy, does it auto check the column name and insert value only if it is the appropriate column and null if not, or it always inserts values in the first columns and the last columns will be empty?
I tried to search it but I haven't find it? can anyone help?
Look for :
When SqlBulkCopyColumnMapping is used, only columns for which mappings are created will be copied.
If you do not create a mapping for a column, it will be ignored by the copy process.