diff --git a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts index 601d3b5393..d01643c124 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts @@ -95,7 +95,16 @@ export function executeQueryQueue( */ export function extractValues(item: IDataObject): string { return `(${Object.values(item as any) // tslint:disable-line:no-any - .map(val => (typeof val === 'string' ? `'${val}'` : val)) // maybe other types such as dates have to be handled as well + .map(val => { + //the column cannot be found in the input + //so, set it to null in the sql query + if (val === null) { + return 'NULL'; + } else if (typeof val === 'string') { + return `'${val.replace(/'/g, '\'\'')}'`; + } + return val; + }) // maybe other types such as dates have to be handled as well .join(',')})`; } diff --git a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts index cd9c308f58..3043600c99 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts @@ -278,7 +278,6 @@ export class MicrosoftSql implements INodeType { const values = insertValues .map((item: IDataObject) => extractValues(item)) .join(','); - return pool .request() .query(