views:

19

answers:

1

Hi All,

I am using MS SQL 2008 to develop one system with Classic ASP.

I want to show 3 Decimal Places the field Datatype is money. I got answer from this http://www.sqlusa.com/bestpractices2005/moneyformat/ .

I use like this in my SQL Statement :

        CONVERT(VARCHAR, CAST(Sell_Price AS Decimal(19, 3))) AS Unit_Price

What I want to know is: Is there more effective way(in performance and usage) than my current one? If there is, please show me. Thanks in advance!

Regards,

RedsDevils

+1  A: 

Personally, I'd consider returning the value as-is unformatted from the database and formatting it for display in the UI instead - leave the formatting up to the front end. After all, the db doesn't know for what use the data it returns is being used for - e.g. something else that runs the query may want the full accuracy returned so would save having multiple different versions.

AdaTheDev
Thanks for reply. I forgot to mention my webpage is to print and I use view there, from the print bridge form I just send record Id. Then I select from view. So How can I format in HTML? Print form is simple HTML.
RedsDevils
Presumably, the query is being run from classic ASP which then iterates round the recordset, writing the data out to the client - so in that loop, you'd format the value from that column before writing it out. e.g. something like (bit rusty with classic ASP!):Response.Write(FormatNumber(rs.Fields("Unit_Price"), 2))
AdaTheDev
Thanks you alot!
RedsDevils