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
 Convert into Varchar

Author  Topic 

yaman
Posting Yak Master

213 Posts

Posted - 2010-01-20 : 09:35:41
Hello sir ,

I have Quantity coloumn
need to covert 1234 into varchar with comma

Need result = 123,4

I am using this query .
select ISNULL(CONVERT(varchar(100), 123456 ),1)

Pls help me out Sir.

Yaman

shan
Yak Posting Veteran

84 Posts

Posted - 2010-01-20 : 09:43:51
You should be doing the data formatting in your front end application \ report.


-Shan
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-20 : 13:16:44
The only thing that I know that is capable of putting commas into string-numbers (but it will convert 1234 to "1,234" and not to "123,4") is CONVERT when converting from MONEY datatype to VARCHAR/CHAR.

See SQL Server documentation for the CONVERT function.
Go to Top of Page

divyaram
Posting Yak Master

180 Posts

Posted - 2010-01-21 : 00:38:27
select CONVERT(varchar(100),Quantity)as Quantity
from'table name'

Regards,
Divya
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-21 : 01:54:32
"select CONVERT(varchar(100),Quantity)as Quantity
from'table name'
"

Useless. Doesn't do what the O/P asked for, and where do you get the idea from that converting a number needs 100 characters width?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-25 : 03:18:10
quote:
Originally posted by divyaram

select CONVERT(varchar(100),Quantity)as Quantity
from'table name'

Regards,
Divya


What will this return?

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-25 : 06:07:55
quote:
Originally posted by yaman

Hello sir ,

I have Quantity coloumn
need to covert 1234 into varchar with comma

Need result = 123,4

I am using this query .
select ISNULL(CONVERT(varchar(100), 123456 ),1)

Pls help me out Sir.

Yaman


can i ask the need for this?
Go to Top of Page
   

- Advertisement -