You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,10 @@ SQLBulkCopy is useful to copy between databases, but truncating the destination
6
6
An alternative workflow is to use SQLBulkCopy to copy to a temporary table and then run SQL MERGE between the temporary table and target.
7
7
Some other solutions that do this require extra work defining the table schemas or are dependant on a SQL stored proc.
8
8
9
-
This library has the following methods:
9
+
## Workflows
10
+
This library has the following workflows.
10
11
11
-
##CopyAndMerge
12
+
### Copy & Merge
12
13
Uses SQLBulkCopy to copy data from a table or view in the source database to a temporary table in the target database before running SQL MERGE from the temporary table to the destination table.
13
14
14
15
The specific steps it performs:
@@ -19,7 +20,7 @@ The specific steps it performs:
19
20
- Run MERGE statement
20
21
- Drop the temp table
21
22
22
-
### Usage:
23
+
####Usage:
23
24
```
24
25
var copyService = new SqlBulkCopyMergeService(sourceDbConnectionString, targetDbConnectionString);
25
26
var result = await copyService.CopyAndMerge(sourceTableOrView, targetTable);
@@ -38,7 +39,7 @@ var columnMappings = new List<ColumnMapping>
38
39
var result = await copyService.CopyAndMerge(sourceTableOrView, targetTable, columnMappings);
39
40
```
40
41
41
-
##CopyLatest
42
+
### Copy Latest
42
43
For source tables that are only ever added to it is more efficient to copy only the new rows into the target table.
43
44
This method copies the latest data determined by the keyColumnName.
44
45
@@ -49,7 +50,7 @@ If no keyColumnName is specified, the primary key is used. If more than one prim
49
50
50
51
The result of the source query is directly copied into the target table using SQLBulkCopy.
51
52
52
-
### Usage:
53
+
####Usage:
53
54
```
54
55
var copyService = new SqlBulkCopyMergeService(sourceDbConnectionString, targetDbConnectionString);
55
56
var result = await copyService.CopyLatest(sourceTableOrView, targetTable, keyColumnName);
0 commit comments