1.0.4 โข Published 6 months ago
@enurhadi24/mssql-syncer v1.0.4
MSSQL Syncer
Sync your stored procedures & functions from SQL Server to files and vice versa.
๐ฆ Installation
npm install -g @enurhadi24/mssql-syncerโ๏ธ CLI Commands
mssql-syncer <command>Available Commands:
| Command | Description |
|---|---|
set-connection <connStr> | Set MSSQL connection string in ADO format |
pull | Pull all procedures/functions from DB into local files |
push | Push all local .sql procedures/functions back to database |
get-connection | Show currently saved MSSQL connection string |
Options
--versionโShow version number--helpโโShow help info
๐ Output Folder Structure
After running pull, your SQL files will be saved in the following structure:
sql/
โโโ procedures/
โ โโโ your_procedure.sql
โโโ functions/
โโโ your_function.sql๐ Optional: Use Environment Variables
If your procedures or functions reference hardcoded database names or linked servers like:
SELECT * FROM [db-prod].dbo.MyTableThey will be dynamically replaced during pull and push using values from a .env file.
Example .env file:
MSSQL_SYNCER_DB_NAME=DUMMY_DB
MSSQL_SYNCER_DB_LINK_SERVER=DUMMY_LINK_SERVERIf the environment variables are not set, no replacements will be made.
๐งช Example Usage
- Set connection:
mssql-syncer set-connection "Server=localhost,1433;Database=argo-tracking;User Id=SA;Password=MyPass@word;Encrypt=false;TrustServerCertificate=true;"- Pull all routines:
mssql-syncer pull- Push all routines:
mssql-syncer push- View saved connection:
mssql-syncer get-connection๐จโ๐ป Author
Created by Endang Nuradi