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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:03:48+00:00 2026-05-21T14:03:48+00:00

A SQL Table (Trades) has three fields AvgProfit, MinProfit and Hold – Hold is

  • 0

A SQL Table (Trades) has three fields AvgProfit, MinProfit and Hold – Hold is a Computed Colum…

If AvgProfit < MinProfit, Hold = ‘Hold’ and if AvgProfit > MinProfit, Hold = ‘Trade’
The Computed Col formula for Hold is as follows.

 SQL Table Trades
 AvgProfit varchar(35)
 MinProfit varchar(35)
 Hold varchar(35)


 (case when CONVERT([decimal](8,4),isnull([AvgProfit],(0)),(0))>=CONVERT([decimal](8,4),isnull([MinProfit],(0)),(0)) then 'Trade' else 'Hold' end)

PROBLEM: Updates cause the AvgProfit to be empty at times and this results in an error when the table references the Hold formula

'Error Converting varchar to numeric'

How do I add IS NULL or EMPTY to the above formula, the ISNULL does not catch AvgProfit = ” ??

  • 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-05-21T14:03:49+00:00Added an answer on May 21, 2026 at 2:03 pm

    Consider typing your database with decimal or numeric columns as paxdiablo has suggested. Is there a reason why those columns are set as varchar?

    Alternatively if you have to keep your varchar columns, try ISNUMERIC(), http://msdn.microsoft.com/en-us/library/ms186272.aspx. It works with all common SQL numeric types. So you query might become:

    ISNUMERIC can be used like this:

    select case when ISNUMERIC('123') = 1 then 1 else 0 end ' returns 1
    select case when ISNUMERIC('xyz') = 1 then 1 else 0 end ' returns 0
    select case when ISNUMERIC(null) = 1 then 1 else 0 end ' returns 0
    

    So your query might become:

    case when isnumeric(AvgProfit) = 1 THEN case([AvgProfit] as decimal) else 0 END
    

    Or something similar.

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

Sidebar

Related Questions

I have a SQL table with three columns X, Y, Z. I need to
I have a SQL Table Roles in DB. I want to find out if
i have a sql table full of address' like this Hattie:07903 000066::Dad:07854 000095::Tom:07903 000044::Allistair:07765
I have a sql table and I have a column which includes data such
I have a MS SQL table with about 8 million records. There is a
I have a SQL Table with the following columns: PROFILE ---------------------------------- Name | DateOfBirth
I have a SQL table: CREATE TABLE [UserTable] ( [ID] [int] NULL, [Name] [nvarchar](50)
I have a SQL table called StudentMarks.which consist of StudentID,SubjectName,SubjectMark I want to write
Having multiple indices for an SQL table, is there a way to know what
I have a 'text' type in a SQL table (BigNote), and a new nvarchar(2000)

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.