How to set env variable

@DemonKing environment variables are only evaluated when flows are started. The runtime gets their values before passing them to individual nodes. The nodes don't know the value came from an env var.

If you change an env var it does not magically cause the node to change its configuration. You'd need to restart Node-RED to pickup the changes.

I understand you have a requirement to dynamically change the mssql connection details. Unless there is a node that already provides that ability, then you are short of options other than creating a custom node of your own.