How to display floats in non-scientific format in sqlcmd on Linux?

Hello,

When I am using sqlcmd on UNIX, it displays some float columns in scientific format i.e. 3.3000000000000002E-2. However, this is not the case in MS SQL Server Management Studio which displays the same number as 0.033. I'd like sqlcmd to display the floats in non-scientific way. How can this be configured?

--Leonid

June 24th, 2015 4:32pm

This cannot be easily configured client-side. It simply depends on the implementation of float-to-string routines. SQLCMD on Unix presumably use the standard routines in the C++ run-time library, whereas SSMS uses .NET. The same difference can be observed on Windows. That is, SQLCMD will also be more prone to switch to scientifc format and also be more prone to display noise digits at the end. As you may now, float numbers are binary numbers with a 53 bit mantissa, of which there typically is no exact representation in the decimal system.

If you need formatting for some specific purpose, you can use the STR() function, for instance:

 SELECT str(pi(), 10, 4)

Free Windows Admin Tool Kit Click here and download it now
June 24th, 2015 6:01pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics