1

I have a code

select CONVERT(NUMERIC, 
  CASE ISNULL(FLEXFIELD4,'') WHEN '' THEN 0 
  ELSE FLEXFIELD4 END )      
FROM DEIT_INDENT_DTL_INBOUND_RXL WHERE IND_INDENT_NO='NEE15SR000003'

which is giving me error

"Conversion failed when converting the nvarchar value '0.000000' to data type int."

i am unable to find the solution.

help me..

Thank you in Advance.

  • Why not use ISNULL(FLEXFIELD4, 0) instead of a CASE statement? – LowlyDBA Feb 4 '15 at 14:53
2

In your code I see a CONVERT(NUMERIC,...) but not a CONVERT(INT,...). So where is the converting to data type int happening?

SELECT CONVERT(INT, N'0.0000')    -- Conversion failed message
SELECT CONVERT(NUMERIC, N'0.0000')-- Converts to 0 

For what it is worth, if you do the following, you also get a '0'.

SELECT CONVERT(INT, CONVERT(NUMERIC, N'0.0000'))

It seems that FLEXFIELD4 is NVARCHAR. If there is some other conversion involved that your code does not show, then that might clarify the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.