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
 General SQL Server Forums
 New to SQL Server Programming
 char data type conversion

Author  Topic 

Teachme
Starting Member

45 Posts

Posted - 2006-09-11 : 15:47:16
im trying to convert char (18) data type to decimal (18,6) but it wont let me do it. It gives an arithematic error. what would be other way to solve this problem. Can i do it with float if yes how so? or any other suggested way. Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-11 : 15:48:55
Try decimal(24,6)
How does your data look like?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-11 : 15:55:13
What does

SELECT char18Col FROM myTable99 WHERE ISNUMERIC(char18Col1) = 0

Give you?

I betcha some rows that won'tt convert to numeric (or decimal for that matter)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-11 : 20:42:07
quote:
Originally posted by X002548

What does

SELECT char18Col FROM myTable99 WHERE ISNUMERIC(char18Col1) = 0

Give you?

I betcha some rows that won'tt convert to numeric (or decimal for that matter)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



ISNUMERIC is not always reliable
http://aspfaq.com/show.asp?id=2390

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-12 : 09:45:28
Very true...but at least it would point out some issues



DECLARE @x char(10)
SELECT @x = CHAR(10)
SELECT ISNUMERIC(@x)
SELECT @x = @x + 'Brett'
SELECT ISNUMERIC(@x)
SELECT @x = 'Brett'
SELECT ISNUMERIC(@x)
SELECT @x = @x + CHAR(10)
SELECT ISNUMERIC(@x)


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-09-12 : 09:56:09
To be sure I follow .... basically all of our careers are being built on the foundation of a company that can't accurately produce a result to basic computer question "is this text data numeric." Oh man I better start looking for a new career.

On second hand it sounds like job security. Cool we are all set for life.

Hope it helps,
Dalton

Blessings aren't so much a matter of "if they come" but "are you noticing them."
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-12 : 10:15:01
It's amazing that a leading Line Feed would be true, but a trailing line feed would be false

I'm sure M$ would call this a feature of ISNUMERIC



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page
   

- Advertisement -