Describe the problem/error/question
What is the error message (if any)? no error message, just when I do UPDATE on execute mssql query it is actioning the same query 5 times and then gives 5 items output. Which is not what I really want
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
{
“name”: “My workflow 6”,
“nodes”: [
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
0,
0
],
“id”: “a39415fa-f021-43ba-bf96-b73ce2c19885”,
“name”: “When clicking ‘Execute workflow’”
},
{
“parameters”: {
“operation”: “executeQuery”,
“query”: “SELECT \n ChargeRateID,\n StartDate,\n EndDate,\n Value,\n ChargeRateTypeID\nFROM ChargeRate \nWHERE ChargeRateID = 790”
},
“type”: “n8n-nodes-base.microsoftSql”,
“typeVersion”: 1.1,
“position”: [
208,
0
],
“id”: “ca7c84d9-498e-4dc2-99f3-36c88202bd7c”,
“name”: “Microsoft SQL”,
“credentials”: {
“microsoftSql”: {
“id”: “1xAFKsC2vJEo7cMk”,
“name”: “Microsoft SQL account”
}
}
},
{
“parameters”: {
“operation”: “executeQuery”,
“query”: “{{ $json.sql }}”
},
“type”: “n8n-nodes-base.microsoftSql”,
“typeVersion”: 1.1,
“position”: [
624,
0
],
“id”: “d82f3cb0-fa12-43e9-928c-531b2e052493”,
“name”: “Microsoft SQL1”,
“credentials”: {
“microsoftSql”: {
“id”: “1xAFKsC2vJEo7cMk”,
“name”: “Microsoft SQL account”
}
}
},
{
“parameters”: {
“jsCode”: “// Get the input data\nconst items = $input.all();\n\n// Build SQL queries for each item\nconst queries = items.map(item => {\n const chargeRateId = item.json.ChargeRateID;\n const effectiveDate = "2025-04-30";\n \n // Calculate date minus 1 day\n const endDate = new Date(effectiveDate);\n endDate.setDate(endDate.getDate() - 1);\n \n // Format as SQL datetime\n const formattedDate = endDate.toISOString().slice(0, 19).replace(‘T’, ’ ') + ‘.000’;\n \n return {\n sql: UPDATE ChargeRate SET EndDate = '${formattedDate}' WHERE ChargeRateID = ${chargeRateId}
,\n chargeRateId: chargeRateId\n };\n});\n\nreturn queries;”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
416,
0
],
“id”: “0b8dde6b-7b84-4703-af38-217ffecaed88”,
“name”: “Code”
}
],
“pinData”: {},
“connections”: {
“When clicking ‘Execute workflow’”: {
“main”: [
[
{
“node”: “Microsoft SQL”,
“type”: “main”,
“index”: 0
}
]
]
},
“Microsoft SQL”: {
“main”: [
[
{
“node”: “Code”,
“type”: “main”,
“index”: 0
}
]
]
},
“Code”: {
“main”: [
[
{
“node”: “Microsoft SQL1”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“active”: false,
“settings”: {
“executionOrder”: “v1”
},
“versionId”: “2b694c83-b5db-4e56-8e01-3d54b1b0fb05”,
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “6fce873ca143621b63a49758525db7cdbd02ecfda1e53899b006d29565fbfcd1”
},
“id”: “eo740xp9EkK61BV7”,
“tags”:
}
Information on your n8n setup
- n8n version: localhost (not docker on postgres) current
- Database (default: SQLite): postgres
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): localhost
- Operating system: windows