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 2000 Forums
 SQL Server Development (2000)
 Adding 2 decimal places to column

Author  Topic 

misterzr
Starting Member

49 Posts

Posted - 2005-06-06 : 12:31:50
I have a column in a table I am trying to add to decimal places to. I have tried the CONVERT(decimal(8, 2), P1BSPR) command but it doesn't seem to work,it is just adding a decimal with 2 zeros afterwards. The data in this column is entered with no zeros and is up to 9 digits long but is actually a Suggested Retail Price and I need to display the decimals. The table is TESTDTA.F5541061 and the column is P1BSPR and the column is presently in the decimal format.

This is the SQL i tried

UPDATE TESTDTA.F5541060
SET P1BSPR = CONVERT(decimal(8, 2), P1BSPR)

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-06-06 : 12:40:18
You need to change the column data type 1st

Look up ALTER TABLE and ALTER COLUMN

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page

misterzr
Starting Member

49 Posts

Posted - 2005-06-06 : 12:52:02
What does it need to be set to? I have it as a decimal now.
Go to Top of Page

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-06-06 : 13:00:19
Oh yes I see from your original post you did say that, sorry.

What is the current scale.
Is it set to 2 or 0??

Beauty is in the eyes of the beerholder
Go to Top of Page

misterzr
Starting Member

49 Posts

Posted - 2005-06-06 : 13:07:15
it is set at zero
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-06-06 : 13:12:14
Have you tried this?
convert(decimal(8, 2),P1BSPR/100.00)


CODO ERGO SUM
Go to Top of Page

misterzr
Starting Member

49 Posts

Posted - 2005-06-06 : 13:21:34
Thanks a ton Micheal and Andy, I have been trying this all morning. I was able to make it work by setting the scale to 2 and then running the convert(decimal(8, 2),P1BSPR/100.00)
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-06-06 : 14:27:17
>>The table is TESTDTA.F5541061 and the column is P1BSPR and the column is presently in the decimal format

JD Edwards ?

Are you sure you want to ALTER TABLE and not just divide things by 100 when you select from it?

- Jeff
Go to Top of Page
   

- Advertisement -