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
 converting varchar

Author  Topic 

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2009-02-19 : 22:41:25
Hi,

Can you help me? I want to convert 20000 which is a varchar datatype to 200.00 in decimal what query can I use?


TNx.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 22:48:33
[code]DECLARE @Var varchar(20)
SET @Var=20000
SELECT @Var*1*0.01
[/code]
Go to Top of Page

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2009-02-19 : 22:54:55
I have a table sample and a field balance:

sample:
balance
20000
10000

and I want to convert it to

sample:
balance
200.00
100.00

what should I do?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 23:00:20
update table
set balance=balance*1*0.01
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-20 : 00:19:24
quote:
Originally posted by eem_2055

Hi,

Can you help me? I want to convert 20000 which is a varchar datatype to 200.00 in decimal what query can I use?
TNx.


hi eem,
why r u storing the values in varchar datatype use decimal or numeric datatype to store the values
Go to Top of Page

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2009-02-20 : 01:41:14
tnx a lot! I made it!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-20 : 02:58:06
welcome
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-02-20 : 04:53:24
quote:
Originally posted by visakh16

welcome


What is your reply to bklr's question?

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-20 : 09:07:45
quote:
Originally posted by madhivanan

quote:
Originally posted by visakh16

welcome


What is your reply to bklr's question?

Madhivanan

Failing to plan is Planning to fail


which question?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-02-20 : 09:11:47
quote:
Originally posted by visakh16

quote:
Originally posted by madhivanan

quote:
Originally posted by visakh16

welcome


What is your reply to bklr's question?

Madhivanan

Failing to plan is Planning to fail


which question?


My question was to OP. Mistakenly I quoted your reply

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-20 : 09:13:56
oh...i see
Go to Top of Page
   

- Advertisement -