https://github.com/pregress/sqlserverbulkcopytool
Command line tool, to copy data between a source an destination SQL server.
https://github.com/pregress/sqlserverbulkcopytool
bulk-loader datapump mssql sql-server tsql
Last synced: 3 months ago
JSON representation
Command line tool, to copy data between a source an destination SQL server.
- Host: GitHub
- URL: https://github.com/pregress/sqlserverbulkcopytool
- Owner: pregress
- License: gpl-3.0
- Created: 2020-09-01T08:42:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-13T06:26:11.000Z (over 5 years ago)
- Last Synced: 2025-10-09T21:38:49.834Z (3 months ago)
- Topics: bulk-loader, datapump, mssql, sql-server, tsql
- Language: C#
- Homepage:
- Size: 76.2 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SqlServerBulkCopyTool

:bullettrain_side: Command line tool, to bulk copy data between a source an destination SQL server.
When you need to move data between 2 SQL server instances you can do this with [SqlBulkCopy](https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlbulkcopy). These tool eliminates the coding and allows for passing in the arguments to copy the data between the 2 servers.


You can download the single exe from the [release page](https://github.com/pregress/SqlServerBulkCopyTool/releases)
# Arguments
| Argument | Description | Required | Default |
| ------------- | ------------- |------------- |------------- |
| source-connectionstring | The connection string of the source database. | yes | |
| source-query | The tSQL query to retrieve data from the source database. | yes | |
| destination-connectionstring | The connection string of the destination database. | yes | |
| destination-tablename | The name of the table in the destination database where the data is inserted. | yes | |
| bulk-insert-timeout | A timeout in seconds to execute the bulk insert. | no | 60 |
| bulk-copy-options | The [SqlBulkCopyOptions](https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlbulkcopyoptions#fields) as provided by Microsoft. | no | Default |
## Examples
### Bulk copy from localhost to a remote sql server with integrated security
```
SqlServerBulkCopyTool.exe --source-connectionstring "Server=localhost;Database=TestDb;Integrated Security=SSPI;" --source-query "SELECT * FROM MySourceTable" --destination-connectionstring "Server=tcp:remote.sample-server.com,1433;Database=TestDb;Integrated Security=SSPI;" --destination-tablename "MyDestinationTable"
```
### Bulk copy from localhost to a remote sql server with bulk copy options: TableLock and CheckConstrains
Executes the bulk copy with table lock and check constraints.
```
SqlServerBulkCopyTool.exe --source-connectionstring "Server=localhost;Database=TestDb;Integrated Security=SSPI;" --source-query "SELECT * FROM MySourceTable" --destination-connectionstring "Server=tcp:remote.sample-server.com,1433;Database=TestDb;Integrated Security=SSPI;" --destination-tablename "MyDestinationTable" --bulk-copy-options TableLock,CheckConstraints
```
### :x: Known limitations
- Table definition between the 2 instances/databases should be the same.
- There is no error handling, assuming the user can understand the exceptions.