User283571144 posted
Hi salman behera,
According to your description, I suggest you could consider using SQL Server Eval
package to achieve your requirement.
SQL Eval.NET is a complete solution which, not only lets you evaluate dynamic arithmetic expression, but lets you use the full C# language directly in T-SQL stored procedures, functions and triggers.
Some example:
DECLARE @items TABLE (Quantity INT, Price MONEY)
INSERT INTO @items
VALUES ( 2, 10 ),
( 9, 6 ),
( 15, 2 ),
( 6, 0 ),
( 84, 5 )
DECLARE @customColumn SQLNET = SQLNET::New('(quantity * price).ToString("$#.00")')
DECLARE @customFilter SQLNET = SQLNET::New('quantity > 3 && price > 0')
-- Select_0: 9, 6.00, $54.00
-- Select_1: 15, 2.00, $30.00
-- Select_2: 84, 5.00, $420.00
SELECT * ,
@customColumn.ValueInt('quantity', Quantity).Val('price', Price).EvalString()
FROM @items
WHERE @customFilter.ValueInt('quantity', Quantity).Val('price', Price).EvalBit() = 1
Best Regards,
Brando