1

I have added a variable in SSIS and I am trying to add tha variable in my expression query. But it says Expression cannot be evaluated Below is my expression query. Please help if you know where I am making mistakes.

SQL Query

SELECT c.CustomerName, o.OrderID from  Customers c
INNER JOIN Orders o ON c.CustomerID=o.CustomerID
Inner Join OrderDetails od ON od.OrderId = o.OrderID
Inner Join Products p on p.ProductID = od.ProductID 
where ISNULL(c.IsResult,0) = 0 and o.CompanyID = @CompanyID

Expression Format

"SELECT c.CustomerName, o.OrderID from  Customers c
    INNER JOIN Orders o ON c.CustomerID=o.CustomerID
    Inner Join OrderDetails od ON od.OrderId = o.OrderID
    Inner Join Products p on p.ProductID = od.ProductID 
    where ISNULL(c.IsResult,0) = 0 and o.CompanyID ="+ @[User::intCompanyID]

Let me know if I am doing it right.

2 Answers 2

1

I found that casting the numeric values to String or Unicode works. so maybe try

ISNULL(c.IsResult,0) = 0 and o.CompanyID ="+ (DT_WSTR,20) @[User::intCompanyID]

Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried the following

"SELECT c.CustomerName, o.OrderID from  Customers c
INNER JOIN Orders o ON c.CustomerID=o.CustomerID
Inner Join OrderDetails od ON od.OrderId = o.OrderID
Inner Join Products p on p.ProductID = od.ProductID 
where ISNULL(c.IsResult,0) = 0 and o.CompanyID = ?"

NOTE: The image is from a different example

enter image description here

Click on the "Parameters" button and you can then selected your parameter from there.

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.