Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:22:14+00:00 2026-06-02T09:22:14+00:00

I have a table which has a column ‘Faktor’ (varchar(50)) which contains expressions like:

  • 0

I have a table which has a column ‘Faktor’ (varchar(50)) which contains expressions like:

1/3
2*9/5
0.567
0.23

No, I am searching a way to execute a select like

select Faktor from Artikel

which should return a column of type decimal with the values

0.333333
3.6
0.567
0.23
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:22:17+00:00Added an answer on June 2, 2026 at 9:22 am

    I’d go with a CLR, something like this (this has the advantage of working in SET based operations whereas the dynamic sql alternatives (i.e. Abduls answer) will not):

    EDIT: Source Code for the CLR dll (Visual Studio 2008) posted here: http://www.heavencore.co.uk/filehub/uploaded/EvalFunction.zip

    If you would prefer to compile the assembly yourself, here is the code:

    Imports System
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Data.SqlTypes
    Imports Microsoft.SqlServer.Server
    Imports System.Runtime.InteropServices    
    
    Partial Public Class UserDefinedFunctions
        <Microsoft.SqlServer.Server.SqlFunction()> _
        Public Shared Function EVAL(ByVal InputExpression As SqlString) As SqlDecimal
            Return Evaluate(InputExpression)
        End Function
    
        Private Shared Function Evaluate(ByVal expression As SqlString) As SqlDecimal
            Dim expressionStr As String = expression.ToString()
            Dim loDataTable = New DataTable()
            Dim loDataColumn = New DataColumn("Eval", GetType(Double), expressionStr)
            loDataTable.Columns.Add(loDataColumn)
            loDataTable.Rows.Add(0)
            Return ParseDecimal(loDataTable.Rows(0)("Eval").ToString(), 0)
        End Function
    
        Public Shared Function ParseDecimal(ByVal InputStr As String, Optional ByVal ReturnIfFail As Decimal = 0) As Decimal
            Dim ParseOutput As Decimal = 0
            If Decimal.TryParse(InputStr, ParseOutput) = False Then
                Return ReturnIfFail
            Else
                Return ParseOutput
            End If
        End Function
    End Class
    

    once installed and bound you could then do this:

    SELECT Faktor, dbo.Eval(Faktor) as Result FROM Artikel
    

    Edit: OK, i have just tested this and it works fine in set-based operations etc, installation was as follows:

    -- Enable the CLR to run user-defined functions
    EXEC sp_configure 
        'clr enabled' ,
        '1'
    GO
    RECONFIGURE
    GO
    
    -- Set the appropriate database security permission
    ALTER DATABASE [TargetDatabase] SET TRUSTWORTHY ON
    GO
    
    -- Import the assembly
    CREATE ASSEMBLY EvalFunction
    FROM 'C:\bin\EvalFunction.dll'  
    WITH PERMISSION_SET = EXTERNAL_ACCESS;
    GO
    
    -- Create the Eval function for easy use
    CREATE FUNCTION dbo.Eval
        (
          @Expression NVARCHAR(255)
        )
    RETURNS DECIMAL(18, 2)
    AS EXTERNAL NAME 
        EvalFunction.[EvalFunction.UserDefinedFunctions].EVAL 
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which has a column for Id and parentId. ParentId contains
I have an old table which has a column like this 1 | McDonalds
I have a table T which has a column C which contains text that
We have a table which has a DATE column d. I'd like to get
I have a table which has two varchar(Max) columns Column 1 Column 2 -----------------------
I have a table which has one TEXT column that looks like this: 0-4
I have a table which has a column called Direct of type char(1). It's
I have a table which has a NVARCHAR column, which could contain a GUID
We have a Oracle 9i database and OrderDetails table which has a column to
I currently have a table which only has a single editable column. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.