Reputation: 33
In my table data is stored as ((1000.000) + 200.000) + 1000.00
Data type of the column is nvarchar
.
I would like get the output while selecting the table as 2200.000
Upvotes: 3
Views: 113
Reputation: 507
this this...
CREATE TABLE table3
(
formula_id int,
formula varchar(max)
)
INSERT INTO table3 (formula_id, formula)
VALUES
(1, '((1000.000) + 200.000) + 1000.00')
DECLARE @formula varchar(max)
SELECT @formula = formula FROM table3 WHERE formula_id = 1
DECLARE @query varchar(max) = 'SELECT ' + @formula
EXEC(@query)
Note : The last 4 query must run at the same time, else no result will be shown.
Upvotes: 1
Reputation: 28741
Use dynamic sql
declare @query varchar(max) = 'select ((1000.000) + 200.000) + 1000.00'
exec(@query)
Upvotes: 1