August 19, 2009 at 5:45 am
Dear All,
I want to implement basic formulas on such values.
These formulas are stored as database values in a table.
like.
Col1 Col2 Col3
2 + 7
9 - 10
Now i want to perform calculation according to these values as expression.
How to solve it?
August 19, 2009 at 6:21 am
I will guess that your example is an "easy" version of the data you actually have but this works for the example. You will have to add lines to the case statement for each operator you have in col2.
CREATE TABLE #temp (col1 VARCHAR(2), col2 VARCHAR(2), col3 VARCHAR(2))
INSERT INTO #temp VALUES ('2','+','7')
INSERT INTO #temp VALUES ('9','-','10')
DECLARE @test-2 VARCHAR(30)
SELECT CASE col2 WHEN '+' THEN CAST(col1 AS INT)+CAST(col3 AS INT)
WHEN '-' THEN CAST(col1 AS INT)-CAST(col3 AS INT)
END
FROM #temp
DROP TABLE #temp
August 19, 2009 at 11:40 pm
Thanks for the Solution.
But I Want to done this by using binary or varbinary.
Because, the operator may vary time by time.
August 21, 2009 at 2:31 am
Can u explain the varbinary thing.
"Keep Trying"
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply