Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cityssm/node-mssql-query-replicate
A simple way to replicate the results of a SQL Server query from one database into a table in another.
https://github.com/cityssm/node-mssql-query-replicate
mssql sql-server
Last synced: 2 months ago
JSON representation
A simple way to replicate the results of a SQL Server query from one database into a table in another.
- Host: GitHub
- URL: https://github.com/cityssm/node-mssql-query-replicate
- Owner: cityssm
- License: mit
- Created: 2024-10-18T13:39:23.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-11-18T23:52:27.000Z (3 months ago)
- Last Synced: 2024-11-23T18:44:46.494Z (3 months ago)
- Topics: mssql, sql-server
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@cityssm/mssql-query-replicate
- Size: 419 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# node-mssql-query-replicate
[![npm](https://img.shields.io/npm/v/@cityssm/mssql-query-replicate)](https://www.npmjs.com/package/@cityssm/mssql-query-replicate)
[![Maintainability](https://api.codeclimate.com/v1/badges/96bf1721c5f5e5c27c6c/maintainability)](https://codeclimate.com/github/cityssm/node-mssql-query-replicate/maintainability)
[![codecov](https://codecov.io/gh/cityssm/node-mssql-query-replicate/graph/badge.svg?token=XEAVOI1Q15)](https://codecov.io/gh/cityssm/node-mssql-query-replicate)
[![Coverage Testing](https://github.com/cityssm/node-mssql-query-replicate/actions/workflows/coverage.yml/badge.svg)](https://github.com/cityssm/node-mssql-query-replicate/actions/workflows/coverage.yml)
[![DeepSource](https://app.deepsource.com/gh/cityssm/node-mssql-query-replicate.svg/?label=active+issues&show_trend=true&token=YtY-ag7MTg2DFyDPqGE39IlF)](https://app.deepsource.com/gh/cityssm/node-mssql-query-replicate/)A simple way to replicate the results of a SQL Server query from database into a table in another.
Helpful for creating a copy of a select table for backup, reporting, or development purposes.
## Installation
```sh
npm install @cityssm/mssql-query-replicate
```## Usage
```javascript
import { replicateQueryRecordsetAsView } from '@cityssm/mssql-query-replicate'const result = await replicateQueryRecordsetAsView(
{
sourceType: 'sql',
sourceSql: `SELECT w.workOrderNumber,
w.workOrderDate,
w.workOrderDescription, s.workOrderStatus
FROM WorkOrders w
LEFT JOIN WorkOrderStatuses s
ON w.workOrderStatusId = s.workOrderStatusId
WHERE year(w.workOrderDate) = @yearParameter`,
sourceParameters: {
yearParameter: new Date().getFullYear()
},
sourceDatabase: {
server: 'productionServer',
user: 'user',
password: 'p@ssword',
database: 'WorkOrderSystem'
}
},
{
destinationViewName: 'WorkOrdersThisYear',
destinationDatabase: {
server: 'devServer',
user: 'devUser',
password: 'passw0rd',
database: 'TestDB'
},
dropOldTables: true
}
)console.log(result)
/*
{
success: true,
destinationRows: 1337,
destinationTableName: '_WorkOrdersThisYear_1729614386783'
}
*/
```## Related Projects
[@cityssm/mssql-multi-pool](https://www.npmjs.com/package/@cityssm/mssql-multi-pool)
A simple way to manage connections to multiple SQL Server databases using the Node.js Tedious package ([node-mssql](https://www.npmjs.com/package/mssql)).[@cityssm/mssql-system-catalog](https://www.npmjs.com/package/@cityssm/mssql-system-catalog)
Helper functions to query a SQL Server database's system catalog.