Solved

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

Posted on 2008-06-16
1
2,110 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sql query help 7 82
Trigger for audit 26 48
SSIS how to COMPARE a data column from different servers? 6 79
SQL Encryption question 2 41
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now