Nodejs mssql
软件包需要@前缀变量
SQL Server也希望使用此类变量:docs中的Variable names must begin with an at (@) sign
在下面的代码示例中,我声明了一个本地SQL var @client_id
,它等于nodejs clientId
const stmt = await new sql.PreparedStatement;
const query = `
DECLARE @client_id INT = @clientId; -- The first is sql var name, second a value from stmt.execute
select * from clients where id = @client_id -- sql local var here`;
stmt.input('client_id', Int);
const result = await stmt.execute({
clientId: 123,
});
如何逃脱此类代码?或更改mssql软件包的@
前缀
注意: