使用npm mssql文档,我正在执行:
try {
let pool = await sql.connect("mssql://user:pass!@dbserver/db?encrypt=true");
let result = await pool.request().query("select * from dbo.db1.tbl");
console.dir(result);
} catch (err) {
console.log(err);
}
然后我得到这个神秘的错误(当我使用Google时):
{ number: 40515,
state: 1,
class: 15,
message: 'Reference to database and/or server name in \'dbo.db1.tbl\' is not supported in this version of SQL Server.',
...
有什么建议吗?
答案 0 :(得分:0)
所以我需要在查询中包括方括号和与数据库名称分开的模式:
let result = await pool.request().query("select * from [dbo].[db1.tbl]");