SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SP is not running
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Niladri20052006
Starting Member

India
4 Posts

Posted - 05/03/2013 :  03:33:17  Show Profile  Reply with Quote
Hi All,

I have written a query and it is running smoothly.

quote:

select sum((case when isnumeric(amount) = 1 then cast(amount as float) end)) as Amount from filetransaction
where fileid =333 AND iscontra=0

But when I am pasting the same in SP it shows me the error

Msg 8114, Level 16, State 5, Procedure bacs_list, Line 17
Error converting data type varchar to float.

Could u please guide me!!

Niladri Sekhar Biswas

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 05/03/2013 :  04:09:48  Show Profile  Reply with Quote
isnumeric is not fully reliable. you may be better off using logic like

select sum(cast(amount as float)) as Amount from filetransaction 
where fileid =333 AND iscontra=0 and amount NOT LIKE '%[^0-9]%'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 05/03/2013 :  04:10:54  Show Profile  Reply with Quote
check this and see why isnumeric is not reliable

SELECT ISNUMERIC('$'),ISNUMERIC('1e4')

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000