Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Error in conversion of ssis task flow

Posted on 2009-12-21
Medium Priority
Last Modified: 2013-11-10
Hello experts

I am trying to execute a sql statement and taking it into a variable 'count', the count value could be any integer, now if i assigned 'string' as its data type, if i change it to int32, it fails. now following that i have 2 exec sql tasks.

From the result set above, if my count is 0, then i should update a table as failure, if not success.

Now the error i am getting is
"The data types "DT_WSTR" and "DT_I4" are incompatible for binary operator ">". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator", i tried to google it, but couldn't solve the problem.

Question by:parpaa
  • 2
  • 2
LVL 32

Expert Comment

by:Brendt Hess
ID: 26097673
The problem is in the basic logic of comparing a string to a number.  Is the number 144 (not the string '144', but the numeric value) greater than or less than 'Cat'?  It's undefined, so you must explicitly cast one of the values (probably the wstr value) to a compatible type for the comparison.

Author Comment

ID: 26097903
ok yes i agree with that, but i dont know why for some reason if i only mention string as the data type it suceeds. here is my variable @count, now my current expression comparison is @count < 1  and @count >0, what would be the syntax to include the cast for one of them?
LVL 32

Accepted Solution

Brendt Hess earned 1200 total points
ID: 26097973
Assuming the variable is the string value, I would:

WHERE Cast(@Count as Int) < 1 AND Cast(@Count As Int) > 0

.... but why a count between 0 and 1?  Just a poor example?

Alternately, create a second variable and CAST it into that, e.g.:

DECLARE @iCt int
SET @iCt = Cast(@Count as Int)
WHERE @iCt >0 AND @iCt < 1

Author Comment

ID: 26098973
i got it..

>>but why a count between 0 and 1?  Just a poor example?
 my count result would be any integer starting 0.f


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question