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)
 Problem with Char(15)

Author  Topic 

mvodnala
Starting Member

6 Posts

Posted - 2008-05-12 : 04:07:02
there are some problems with char(15) columns:

(1) Purely fractional numbers sometimes have the first zero removed. So "0.03875" is stored as ".03875"
(2) Some numbers have trailing zeros added. So "70.7" is stored as "70.700000".

Can someone help how to overcome the formatting errors.

Thanks,

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-12 : 04:34:41
Are you trying to insert these values from some other column? If yes, what's the datatype of source field?
Go to Top of Page

mvodnala
Starting Member

6 Posts

Posted - 2008-05-12 : 04:37:27
Am trying to fetch these values from a table(where it is stored as .355) not inserting..
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-12 : 04:38:44
Whats data type of column containing this?
Go to Top of Page

mvodnala
Starting Member

6 Posts

Posted - 2008-05-12 : 04:41:12
Char datatype
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-12 : 04:43:25
quote:
Originally posted by mvodnala

Char datatype


and your destination column is also char?
Go to Top of Page

mvodnala
Starting Member

6 Posts

Posted - 2008-05-12 : 04:44:03
yes
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-12 : 04:45:25
quote:
Originally posted by mvodnala

yes


Then i dont think you'll have a problem unless the lengths are different.
Go to Top of Page

mvodnala
Starting Member

6 Posts

Posted - 2008-05-12 : 05:00:56
i need to put the value .355 has 0.355 at destination there am getting prob...
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-12 : 05:16:49
SELECT CASE WHEN LEFT(Col1, 1) = '.' THEN '0' ELSE '' END + Col1
FROM Table1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-12 : 05:18:51
This is purely formatting issue. Why do you want to handle it at database level rather than in your application?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

mvodnala
Starting Member

6 Posts

Posted - 2008-05-12 : 05:37:43
at application level i cant check, it is some other system hence i want to feed correct values to the system by avoiding these kind of errors at database level itself...
Go to Top of Page
   

- Advertisement -