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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:38:52+00:00 2026-05-27T18:38:52+00:00

i am getting the following error: Incorrect syntax near ‘cast’, expected ‘AS’. on this

  • 0

i am getting the following error:

Incorrect syntax near 'cast', expected 'AS'.

on this line:

  use SalesDWH
go
if (select isnumeric(result))=1
begin
select  max(cast(result) as decimal(10,2)) from testresults 

end

testresults table contains about 21 million rows of data.

what am i doing wrong? thanks so much.

thank you everyone for you rhelp.

i’ve changed the code to:

 use SalesDWH
    go
    if (select isnumeric(result))=1
    begin
    select  max(cast(result as decimal(10,2))) from testresults

    end

and now i am getting error:

Msg 207, Level 16, State 1, Line 1
Invalid column name 'result'.

it’s definitely a valid column

i took kris’ suggestion and did this:

 use SalesDWH
    go
    SELECT MAX( CAST( [Result] AS DECIMAL(9,2) ) )
FROM [testresults]
WHERE ISNUMERIC( [Result] ) = 1

    and dbo.isReallyNumeric([Result]) = 1 
    and dbo.isReallyInteger([Result]) = 1 

the functions are here http://classicasp.aspfaq.com/general/what-is-wrong-with-isnumeric.html

and the result that i got was NULL!!!!!

i need a numeric result. what am i doing wrong?

here is a sample of the data:

625857  AMPH-AMPHETAMINES   357.1   EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625858  AMP_C-Amphetamine   NEGATIVE    EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625859  BARB-BARBITURATES   7.1 EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625860  BENZ-BENZODIAZEPINES    1.2 EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625861  COCN-COCAINE METABOLITES    -105.5  EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625862  CR-CREATININE (CHEMICAL)    57.8    EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625863  ETOH-ETHANOL    134.5   EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625864  METAMP_C-Methamphetamine    NEGATIVE    EBB74CF9-D12D-4FBC-917F-91D9DAC169F3
625865  METD-METHADONE  -32.3   EBB74CF9-D12D-4FBC-917F-91D9DAC169F3

thank you for all your help. i think i am getting closer:

 select MAX(cast(char_value as decimal(10,2))) from
        (SELECT 
    Char_Number = CASE 
        WHEN id <= 255 THEN RTRIM(id) 
        ELSE '-' END, 
    Char_Value = RTRIM(CASE 
        WHEN id <= 255 THEN CHAR(id) 
        ELSE result END), 
    is_numeric = ISNUMERIC(result), 
    is_really_numeric = dbo.isReallyNumeric(result), 
    is_really_integer = dbo.isReallyInteger(result) 
FROM 
    testresults 
WHERE 
    ISNUMERIC(result) = 1 
    OR dbo.isReallyNumeric(result) = 1 
    OR dbo.isReallyInteger(result) = 1 
 )

    where is_really_numeric=1

but i am getting this error:

Msg 156, Level 15, State 1, Line 20
Incorrect syntax near the keyword 'where'.
  • 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-27T18:38:53+00:00Added an answer on May 27, 2026 at 6:38 pm

    Try this one

    use SalesDWH
    go
    SELECT MAX(CAST(Result AS DECIMAL(10,2))) FROM testresults WHERE isnumeric(result)=1
    

    But if you get NULL as a result even with this:

    and dbo.isReallyNumeric([Result]) = 1 
    and dbo.isReallyInteger([Result]) = 1 
    

    then this may be the actual result – there is no any numberic values in the column

    OR

    the really numberic values of column are left- or right-padded with spaces etc…

    OR

    you stripe all the floats with this dbo.isReallyInteger([Result]) = 1 and you have no pure integers in the table

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

Sidebar

Related Questions

I am getting following error in my query System.Data.SqlClient.SqlException: Incorrect syntax near the keyword
I am getting following error ERROR:- Incorrect syntax near '+'. while executing following T-Sql
I'm following the provided instructions but is not working. I'm getting this error: INFO:
I'm trying to do the following in a proc, but getting an incorrect syntax
Am getting following error message on calling WCF service: The formatter threw an exception
I am getting following error when I am trying to get WebResponse using WebResponse
I am getting following error message when using Doctrine ORM in Codeigniter. ( !
SOLVED in the last answer im getting following error, dunno where and why? cause
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
I have done simple java app for blackberry, while building am getting following error.

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.