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
 Can someone tell me how to put a $ with numbers?

Author  Topic 

mistylove98
Starting Member

5 Posts

Posted - 2015-04-14 : 12:12:02
I have a query where I have to use the convert function to return the unitprice as a decimal with 2 digits to the right of the decimal and a $ to the left of the number like 10 should be $10.00 Can anyone tell me how do i insert the $ this is my code so far

SELECT CONVERT(varchar, UnitPrice, 1) AS varchartotal
FROM dbo.[Order Details]

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2015-04-14 : 12:27:01
See CAST and CONVERT in Books Online (the SQL Server help file).



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

Maithil
Starting Member

29 Posts

Posted - 2015-04-15 : 05:37:02
Hi,

You can Use any one from below two select statement

select '$'+cast(CAST(10 as money) as nvarchar)
-----------
select '$'+CAST(Convert(money,10) as nvarchar)
Go to Top of Page
   

- Advertisement -