Solved

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

Posted on 2008-06-16
1
2,115 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:bcllc
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 125 total points
ID: 21795102
SELECT cast(lotSize as varchar(100) ) + ' ' + lotSizeType AS lotSize
FROM Listings
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question