Advertisement

06.16.2008 at 09:18AM PDT, ID: 23488695
[x]
Attachment Details

Convert/cast a decimal to a string (without rounding)

Asked by bcllc in SQL Server 2005

Tags: Microsoft, SQL Server, 2005

Simple one here, I've got two fields, lotSize (decimal 18,2) and lotSizeType (varchar(50)), which store things like 2.34 + Acres, or 12345 Square Feet. I've got an SP where I want to get the EXACT value out of lotSize and append it to lotSizeType as a string:

SELECT lotSize + ' ' + lotSizeType AS lotSize
FROM Listings
 

What I currently have is:

SELECT LTRIM(STR(lotSize)) + ' ' + lotSizeType AS lotSize
FROM Listings



This is rounding the lotSize value, and so instead of 4.84 Acres, I get 5 Acres. How best to CAST/CONVERT/ETC?
Start Free Trial
[+][-]06.16.2008 at 09:22AM PDT, ID: 21795102

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: Microsoft, SQL Server, 2005
Sign Up Now!
Solution Provided By: aneeshattingal
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628