Monday, February 20, 2012

Reduce string to binary comparison

Is it possible to create a binary comparison from a string? For numbers, you can use this syntax:

Value * (1-ABS(SIGN([Column Name] - [Desired Value))) which will evaluate to one or zero.

For strings, I thought it would be easier. I tried:

Value * ([Column Name]=[Desired Value])

But that does not work. I get an "incorrect syntax near = error. I am looking for a solution that does not rely on the case statement.

Thanks,

AndrewComparison operators return a Boolean data type - TRUE, FALSE, UNKNOWN. As such, you cannot perform arithmetic on them. You are stuck with a CASE statement, or you could use a UDF to do the comparison and return a 1 or 0.

Terri|||Thanks for your response.

Andrew

No comments:

Post a Comment