• In this example the size of the table of literals is unlimited. However aditional coding is needed tu use variable names i.e. A, B, C, etc. A little fooling around with this thing and it might serve the most elementary uses.

    DECLARE @ExprCollection Table(expr VARCHAR(100) )

    INSERT INTO @ExprCollection(expr)

    SELECT '2+1'

    UNION ALL

    SELECT '5*2'

    UNION ALL

    SELECT '6/3'

    drop table #ExpValueTable

    CREATE TABLE #ExpValueTable ([value] decimal(18,4),[Id_Exp] [VARCHAR](100) PRIMARY KEY)

    declare ExprCursor cursor

    for

    select * from @ExprCollection

    declare @Expr as varchar(100), @SQL varchar(max)

    open ExprCursor

    fetch next from ExprCursor into @Expr

    while @@Fetch_Status = 0

    BEGIN

    set @SQL = ' INSERT INTO #ExpValueTable ([value],[Id_Exp]) SELECT ' + @expr + ' AS ExpValue,''' + @expr +''' As Exp'

    fetch next from ExprCursor into @Expr

    exec (@SQL)

    END

    close ExprCursor

    deallocate ExprCursor

    select * from #ExpValueTable