Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Error whiel converting data type to numeric

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2011-06-06 : 00:50:08
Hi All,

I have table with the column nvarchar(max) and i am usign below statement to convert it into numeric and append % symbol to it.

CONVERT(VARCHAR(4),CONVERT(INT,ROUND(CAST("[Measures].[MTH Chg%]" AS DECIMAL(4,2)), 0))) + '%'


Pls help me.


Thanks,
Gangadhara MS
SQL Developer and DBA

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-06-06 : 01:38:45
Your column has some data that can't be converted to numeric.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

lappin
Posting Yak Master

182 Posts

Posted - 2011-06-06 : 07:20:58
Find the non- numeric rows:
SELECT *
FROM tableName
WHERE ISNUMERIC(columnName)<> 1
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-06-06 : 09:08:11
Be careful. ISNUMERIC can (and does) return 1 for values that cannot cast to Numeric.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -