Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

TSQL Convert 3.100000000000e+003 to human readable format (Double) Expand / Collapse
Author
Message
Posted Monday, February 04, 2013 6:35 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, May 01, 2013 1:33 PM
Points: 368, Visits: 156
I have a stored procedure that returns a XML string, I have a field 'Quantities' which contains an odd value : 3.100000000000e+003.
I know it's a numeric value and it is valid but is there a way to format it in TSQL so it's human readable?

Thanks.
Post #1415268
Posted Monday, February 04, 2013 6:50 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, May 16, 2013 9:16 AM
Points: 2,236, Visits: 6,486
Something like this?

--== SAMPLE DATA ==--
DECLARE @XML XML = '<YourXML><TheData value="3.100000000000e+003" /></YourXML>';
--== VIEW SAMPLE DATA==--
SELECT @XML;
/* Looks like this: -
<YourXML>
<TheData value="3.100000000000e+003" />
</YourXML>
*/
--==Convert from scientific notation==--
SELECT Data.value('(@value)[1]', 'REAL')
FROM @XML.nodes('./YourXML/TheData') yourXMLData(Data);

If not. . . supply sample data and expected result-set in your question. Otherwise, people just have to guess what you want.



Not a DBA, just trying to learn

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better, quicker answers on SQL Server performance related questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/



If you litter your database queries with nolock query hints, are you aware of the side effects?
Try reading a few of these links...

(*) Missing rows with nolock
(*) Allocation order scans with nolock
(*) Consistency issues with nolock
(*) Transient Corruption Errors in SQL Server error log caused by nolock
(*) Dirty reads, read errors, reading rows twice and missing rows with nolock


LinkedIn | Blog coming soon (for sufficiently large values of "soon" )!
Post #1415274
Posted Monday, February 04, 2013 7:08 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, May 01, 2013 1:33 PM
Points: 368, Visits: 156
Thank you, yes, I just came around the problem with the same type of solution.

Something like : str(cast('252536e+003' as real) )


Thanks again.
Post #1415282
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse