1 //自增列重新生成:SqlBulkCopy bc = new SqlBulkCopy(conn) 2 //自增列保留原值:SqlBulkCopy bc = new SqlBulkCopy(conn,SqlBulkCopyOptions.KeepIdentity) 3 using(SqlBulkCopy sbc = new SqlBulkCopy(conn,SqlBulkCopyOptions.KeepIdentity)) 4 { 5 sbc.DestinationTableName = tableName; 6 foreach (string col in colList) 7 { 8 sbc.ColumnMappings.Add(col, col); 9 } 10 sbc.BulkCopyTimeout = 0; 11 sbc.WriteToServer(dt); 12 }
时间: 2024-10-19 10:12:09