tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.22k stars 464 forks source link

Support sqlcmd scripts #978

Open tracker1 opened 4 years ago

tracker1 commented 4 years ago

Was thinking it would be really cool to support the additional features of sqlcmd / osql in a command parameter...

sql.command(script, [commandVars])

For example:

await sql.command(script, {DatabaseName:'foo'});

I'm not entirely sure what else sqlcmd does in practice, but could be a decent idea.

dhensby commented 4 years ago

Whilst this sounds cool and nifty, I'm not sure where the need is for this and it's not something I have the time to concentrate on - I'd happily accept PRs for improvements, but this feels like a low priority for me at the moment

tracker1 commented 4 years ago

@dhensby totally understood... also, given the need to work, potentially with multiple databases and queries with GO statements, etc... not sure it's within a good scope of this project. I'm working on creating an abstraction to make it easier to find/use sqlcmd executable directly on a host, or in a locally configured docker container (assuming docker executable and container configured).

I was just reading through the generated file, and thought it might not be too much work to support such scripts. Mainly from db export/backup and from db projects in visual studio. (aside: migrating from a vs sql project to a version-script solution, so starting point is a set of these scripts).

https://github.com/tracker1/node-ms-sqlcmd