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
+20-6Lines changed: 20 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,14 @@
1
1
# SQL Bulk Copy & Merge
2
2
3
+
This library aims to make copying table data between SQL databases easier.
4
+
3
5
SQLBulkCopy is useful to copy between databases, but truncating the destination table each time before copying is not always possible or efficient.
6
+
An alternative is to use SQLBulkCopy to copy to a temporary table and then run SQL MERGE between the temporary table and target.
7
+
Some other solutions that do this require extra work defining the table schemas or are dependant on a stored proc.
4
8
5
-
To solve this problem, this .NET library has the following methods:
9
+
This .NET library has the following methods:
6
10
7
-
###CopyAndMerge
11
+
## CopyAndMerge
8
12
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.
9
13
10
14
The specific steps it performs:
@@ -15,7 +19,7 @@ The specific steps it performs:
15
19
- Run MERGE statement
16
20
- Drop the temp table
17
21
18
-
Usage:
22
+
### Usage:
19
23
```
20
24
var copyService = new SqlBulkCopyMergeService(sourceDbConnectionString, targetDbConnectionString);
21
25
var result = await copyService.CopyAndMerge(sourceTable, targetTable);
<Description>Copy data from a table in one database to a table in another database. It does not TRUNCATE the target table. Uses SQLBulkCopy behind the scenes.</Description>
0 commit comments