MSSQL plus declaration error

When i attempt to query with userinput, i get an error claiming my var is undeclared, yet following the node page, this is how it should be declared, right?

msg.topic = `
   SELECT DISTINCT [EmployeeID (SIDxxxx)] 
   FROM NR_EmployeeInformation
   WHERE Email = @userInput
      OR EmployeeID = @userInput
      OR Tel = @userInput
      OR Voornaam = @userInput
      OR Achternaam = @userInput
      OR CONCAT(Voornaam, Achternaam) = @userInput
      OR CONCAT(Achternaam, Voornaam) = @userInput
      OR Email LIKE '%' + @userInput + '%'
      OR Tel LIKE '%' + @userInput + '%'
      OR Voornaam LIKE '%' + @userInput + '%'
      OR Achternaam LIKE '%' + @userInput + '%';
      OR EmployeeID LIKE '%' + @userInput + '%'
`;

msg.params = { name: 'userInput', Value: msg.payload };
return msg;

3/25/2025, 2:58:06 PMnode: debug 6
SELECT DISTINCT [EmployeeID (SIDxxxx)] FROM NR_EmployeeInformation WHERE Email = @userInput OR EmployeeID = @userInput OR Tel = @userInput OR Voornaam = @userInput OR Achternaam = @userInput OR CONCAT(Voornaam, Achternaam) = @userInput OR CONCAT(Achternaam, Voornaam) = @userInput OR Email LIKE '%' + @userInput + '%' OR Tel LIKE '%' + @userInput + '%' OR Voornaam LIKE '%' + @userInput + '%' OR Achternaam LIKE '%' + @userInput + '%'; OR EmployeeID LIKE '%' + @userInput + '%' : msg : Object
object
_client: object
payload: "SIDp"
topic: "↵   SELECT DISTINCT [EmployeeID (SIDxxxx)] ↵   FROM NR_EmployeeInformation↵   WHERE Email = @userInput↵      OR EmployeeID = @userInput↵      OR Tel = @userInput↵      OR Voornaam = @userInput↵      OR Achternaam = @userInput↵      OR CONCAT(Voornaam, Achternaam) = @userInput↵      OR CONCAT(Achternaam, Voornaam) = @userInput↵      OR Email LIKE '%' + @userInput + '%'↵      OR Tel LIKE '%' + @userInput + '%'↵      OR Voornaam LIKE '%' + @userInput + '%'↵      OR Achternaam LIKE '%' + @userInput + '%';↵      OR EmployeeID LIKE '%' + @userInput + '%'↵"
_msgid: "35b372c405abf8d8"
params: object
query: "↵   SELECT DISTINCT [EmployeeID (SIDxxxx)] ↵   FROM NR_EmployeeInformation↵   WHERE Email = @userInput↵      OR EmployeeID = @userInput↵      OR Tel = @userInput↵      OR Voornaam = @userInput↵      OR Achternaam = @userInput↵      OR CONCAT(Voornaam, Achternaam) = @userInput↵      OR CONCAT(Achternaam, Voornaam) = @userInput↵      OR Email LIKE '%' + @userInput + '%'↵      OR Tel LIKE '%' + @userInput + '%'↵      OR Voornaam LIKE '%' + @userInput + '%'↵      OR Achternaam LIKE '%' + @userInput + '%';↵      OR EmployeeID LIKE '%' + @userInput + '%'↵"
queryMode: "query"
queryParams: array[0]
error: object
class: 15
code: "EREQUEST"
lineNumber: 4
message: "Must declare the scalar variable "@userInput"."
details: "Must declare the scalar variable "@userInput"."
name: "RequestError"
number: 137
procName: ""
serverName: "SQL16PROD2\V02"
state: 2
toString: function

This is not valid usage.


This line has a semicolon




Try using the editor instead

1 Like