[英]SQL Server in Node.js: Query works on server, but not via the Node.js driver
The following query is generated by a script, inserted to our SQL Server and afterwards logged to the console.以下查询由脚本生成,插入到我们的 SQL 服务器,然后登录到控制台。
Fields are anonymized:字段是匿名的:
INSERT INTO
T_OUTLOOK_Kalendereintrag (
field1,
field2,
field3,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
[fieldN WithSpace],
[fieldN WithSpace],
[fieldN WithSpace],
[fieldN WithSpace],
[fieldN WithSpace],
[fieldN WithSpace],
[fieldN WithSpace],
[fieldN WithSpace],
[fieldN WithSpace],
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN,
fieldN
)
VALUES
(
'a2714a8c-3718-42db-87b5-e5c570f84151',
null,
'1355',
'06.08.2019 00:00:00',
'201908',
'06.08.2019 12:58:00',
'06.08.2019 18:58:00',
6,
'Comment field',
'test',
'0900',
'0900',
null,
null,
0.75,
6,
0,
'PT',
'R4200',
0,
0,
null,
null,
0,
0,
'',
0,
'Jane Doe',
'20.09.2019 11:03:41',
'20.09.2019 11:03:41',
null,
null,
null,
'Jane Doe',
null,
null,
null,
1,
1,
'1',
'1',
'20.09.2019 11:03:41',
'20.09.2019 11:03:41',
0
)
On inserting to the server via the following code通过以下代码插入服务器
try {
await sql.connect(`mssql://${config.get('config.dbConfig.user')}:${config.get('config.dbConfig.pw')}@${config.get('config.dbConfig.server')}/${config.get('config.dbConfig.dbTest')}`);
result = await sql.query(sqlQuery);
sql.close();
} catch (e) {
sql.close();
logger.error(e);
console.log(e);
}
I get the following error:我收到以下错误:
{ number: 242,
state: 3,
class: 16,
message:
'The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.',
serverName: 'hostname',
procName: '',
lineNumber: 1,
name: 'ERROR',
event: 'errorMessage' } },
However, when taking the above query and querying directly via HeidiSQL everything works totally fine?但是,当进行上述查询并直接通过 HeidiSQL 查询时,一切正常吗? Any ideas?
有任何想法吗? I can't find the error nor where to look for it.
我找不到错误,也找不到在哪里寻找它。
Apparently the date format was the problem.显然日期格式是问题所在。 Should have been 2019-08-06 18:58:00'
应该是 2019-08-06 18:58:00'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.