Solved

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

Posted on 2008-06-16
1
2,119 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…

732 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