Solved

FOrmat Float

Posted on 2006-10-25
4
525 Views
Last Modified: 2011-04-14
Hello all, I have a insert statement (below) in which the @pDifference is a float.  If the variable contains 2.7777764646 for example, I want to format so that the insert just puts 2.7 into the database.  Please help!  Urgent!
0
Comment
Question by:jwebster77
  • 2
4 Comments
 

Author Comment

by:jwebster77
ID: 17804763
cast(@pDifference as decimal(5,1))

This is how I did it for anyone interested.
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17804767
SELECGT ROUND(@pDifference, 1) AS RoundedValue
0
 
LVL 23

Accepted Solution

by:
adathelad earned 500 total points
ID: 17804918
jwebster77 - your solution will put 2.8 into the database though?

If you want the value rounded down to 2.7 instead:
cast(floor(@pDifference * 10) as decimal(5, 1)) / 10
0
 

Author Comment

by:jwebster77
ID: 17805164
Good point.  I am not sure if we want to round down yet or not...  The example show was more for "decimal places" being limited to 1. I'll give you the credit for the answer though, just in case I need to use the floor function!
0

Featured Post

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

910 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

22 Experts available now in Live!

Get 1:1 Help Now