0
좋은 날에 내가 SQL에서 일부 데이터를 내보낼를 저장하고 나중에 해당 데이터를 비교하려고 시도하고, 쿼리 (Node.js를 & 노드 MSSQL)
을 테이블 반환 매개 변수 (TVP)를 사용 할 수 없습니다 같은 쿼리의 결과. 이 작업을 수행하는 가장 간단한 방법은 TVP를 사용하는 것입니다. 그러나 node-mssql에서 작동하지 않는 것으로 보이고 TVP와 관련된 오류가 발생하지 않습니다. 나는 오류가 발생
var _sql = require('mssql');
var _conn = new _sql.Connection(/*CONN STR*/,function(err) {
if (err) {
console.log('ERROR Unable to connect to DB:',err);
} else {
var oInitRequest = new _sql.Request(_conn);
oInitRequest.query(/*DB QUERY*/)
.then(function(oInitRS) {
console.log('oInitData:',oInitRS);
var oInitTable = oInitRS.toTable();
console.log('oInitTable:',oInitTable);
var oCheckRequest = new _sql.Request(_conn);
oCheckRequest.input('oInitTable',_sql.TVP,oInitTable);
oCheckRequest.query('SELECT * FROM @oInitTable')
.then(function(oCheckRS) {
console.log('oInitTable re-read:',oCheckRS);
})
.catch(function(err) {
console.log('ERROR unable to pass oInitTable to new query',err);
});
})
.catch(function(err) {
console.log('ERROR Unable to retrieve oInitData',err);
});
}
});
:
나는 코드를 실행
ERROR unable to pass oInitTable to new query
{
[RequestError: Could not find stored procedure 'sp_executesql'.]
name: 'RequestError',
message: 'Could not find stored procedure \'sp_executesql\'.',
code: 'EREQUEST',
number: 2812,
lineNumber: 1,
state: 1,
class: 16,
serverName: /*REDACTED*/,
procName: '',
precedingErrors: []
}
왜 그 첫 번째 쿼리 만 저장 프로 시저가 존재하지 않았기 sp_executesql을 성공적를 사용하여 쿼리를 실행할 수 두 번째?
내가 오류를 알리는 작동하지 않았다 준비된 문하지만 매개 변수도 표준을 사용하여 시도:
{
[RequestError: Could not find prepared statement with handle 0.]
name: 'RequestError',
message: 'Could not find prepared statement with handle 0.',
code: 'EREQUEST',
number: 8179,
lineNumber: 1,
state: 4,
class: 16,
serverName: /*REDACTED*/,
procName: 'sp_execute',
precedingErrors: []
}
사람은 특히 저장 프로 시저를 생성하지 않고 TVP을 수용 할 수있는 쿼리를 얻는 방법을 알고 있나요 1 개의 쿼리에 대해?
오타가있는 스크립트 (/ s/oRequest/oCheckRequest)에 대해 편집되었습니다. – KaoSDlanor