UDF to evaluate a condition using select statement
===

Here is UDF function requirement.


CREATE FUNCTION [dbo].[ConditionEvaluation]

(@condEquation VARCHAR(MAX),
@condParameters VARCHAR(MAX
)
RETURNS bit
AS

--
the values of @condEquation and  @condParameters  are

Example 1: @condEquation = (C01 & C02) and @condParameters =10

Example 2: @condEquation = ((C01 & C02) | C3) and @condParameters =101

so for every C series condition in @condEquation  there will be corresponding 0 or 1 values are provided in the second parameter i.e. @condParameters.

I want to evaluate the above condition as ...

Example 1: select (1 & 0) 

Example 2: select ((1 & 0) | 0) 

Parameter @condEquation might contain any number of Cs in the equation. But there will be corresponding number of bits in the parameter2.

I am utilizing the condition evaluation capability of SQL Select statement here.

Wants to return the evaluated result as 0 or 1.

How to do that using a UDF?
SQL Server 2008.

Thank you,
Smith







