Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hello I have following code in my procedure it works fine except when i run it it gives me value of for example 1.127790001 while i just want it to round off upto four decimal point like 1.1278..... any ideas how to do it? Thanks

SQL
SET @tg=Cast (@tr as numeric (7,4))*Cast (@tg as numeric(7,4))+Cast(@tg as numeric (7,4))

Select @tg
Posted
Updated 27-Nov-11 17:27pm
v2
Comments
[no name] 27-Nov-11 23:28pm    
EDIT: added <pre> tag

Try this one:

SQL
DECLARE @num DECIMAL(7,4)
SET @num = 1.1234567

SELECT @num


This will display 1.1234

Please mark as answer if this solved your problem

Best regards,
Eduard
 
Share this answer
 
v2
Use Round function
PRINT ROUND(1.127790001,4)
 
Share this answer
 
Use the following Systax :
ROUND ( numeric_expression , length [ ,function ] )

Example :
SELECT ROUND(123.9994, 3), ROUND(123.9995, 3)
GO
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900