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 7850963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:02:57+00:00 2026-06-02T19:02:57+00:00

I have a table containing columns id (int), logical expression (varchar) and result (bit).

  • 0

I have a table containing columns id(int), logical expression(varchar) and result(bit). The logical expression is stored in a varchar which I need to evaluate and put the result into the result column. For example, the column could contain:

'1=1'
'2<3 AND 1^1=1'
'3>4 OR 4<2'

The result column should then contain

1
0
0

Currently I am using a cursor to navigate the rows and using dynamic sql to evaluate the expression.

"IF(" + @expression + ") SET @result = 1" 

Is there a better, more efficient way to do this? I would ideally like to get rid of the cursor. Any ideas? Would this be better performed using an assembly?

  • 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-02T19:02:58+00:00Added an answer on June 2, 2026 at 7:02 pm

    I’d go with a CLR.

    I posted a very similar answer here: Convert string with expression to decimal

    infact, the above answer would work fine unmodified for (and any other simple expressions):

    SELECT dbo.eval('1=1' )
    SELECT dbo.eval('3>4 OR 4<2' )
    

    However, it would fail for the one using the ^ (caret) operator – you would need to tweak the CLR to handle the bitwise XOR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of users containing the following columns: | User_ID (int) |
I have a table containing around 100 columns, is it to possible to do
We have a large table (450 million rows containing 34 columns of numeric or
I have a java class containing all the columns of a database table as
I have a table containing view/click records. The time is stored in a unix
I have a table [Tbl1] containing two fields. ID as int And TextValue as
I have a huge table containing 161 million rows. The table structure is entryid(varchar),
I have a table: id:int revision:int text:ntext In general I will need to retrieve
I have a SQL Server DB containing a registrations table that I need to
I have a table with 6 columns containing HTML content with some markups in

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.