Why does SQLCMD doesn't return values returned by query?

I have a query that returns the price of a bunch of products.
The prices contain 4 decimals but I want 2 decimals so I use ROUND.

select
ROUND (items.articleprice,2) as Price
from items

The query works but when I use SQLCMD to run the query it still returns 4 decimals instead of 2.

How can I make SQLCMD to return just 2 decimals?
Clyde_RadcliffeAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
please use CAST, eventually on TOP of ROUND.

select CAST(items.articleprice AS DECIMAL(20,2)) as Price from items

Open in new window

0
 
yjchong514Commented:
0
 
TempDBACommented:
or round the value that you are getting as result from sqlcmd.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Clyde_RadcliffeAuthor Commented:
@yjchong514 and TempDBA,

The query is already in and .sql file.
And the uery already contains round.
0
 
TempDBACommented:
wow. Then I will recommend rechecking the code again.
0
 
Clyde_RadcliffeAuthor Commented:
@TempDBA

There isn't much code involved.
The actual value of the articleprice is 12.98999

When I enter the queryselect ROUND (items.articleprice,2) as Price from items manually it returns the value 12.99 wich is correct.

When I place the same query in an .sql file and run it with cmdsql it returns the value 12.98999 wich is incorrect.
0
 
TempDBACommented:
What I meant while writing using round in the above comment was : Instead of using round function in the current place, use it at the time you are displaying.

Anyway, will post if any other idea is clicked.
0
 
Clyde_RadcliffeAuthor Commented:
Works like a charm!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.