Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

Programming

TSQL: The Discovery

[2022-06-29] Originally, this post was written back in July 2013 on Dewacorp's blog website. We consolidated all tech blogs into this place and we reformat the content to suit Dewapost's guidelines.   

The Findings

In SQL Server 2005, there is no inbuilt ROUNDUP and ROUNDDOWN function like on other SQL Server 2008 or 2012. To substitute this function is by adding/deducting .5 of the decimal point. For instance,  the number is 12345.96124  and you want to 2 decimal points round up or round down is by adding/deducting 0.005

DECLARE @num1 FLOAT;

DECLARE @num2 FLOAT;

SET @num1 = 123.12345;

SET @num2 = 12345.96124;




SELECT @num1 AS ‘Number 1’,

@num2 AS ‘Number 2’,

CAST(@num2 AS INTEGER) AS ‘Integer’,

FLOOR(@num2) AS ‘Floor/round down’,

CEILING(@num2) AS ‘Ceiling/round up’,




ROUND(@num2+0.005,2) AS ‘Round-Up with 2 decimal point’,

ROUND(@num2-0.005,2) AS ‘Round Down with 2 decimal point’

The End

Congratulation on reaching the end of this article. We hope that we have been able to shed some light on outlining the TSQL: the discovery.

We write this in such a way that this is not a fixed article. Like in this journey, we learn as we go and we re-write some parts so please keep pinging with this article.




We also would love to hear about how you deal with the situation and what problems you might be facing. Please feel free to leave us a comment below this article and let us know if you have any questions that we can answer! Thanks again!

If you want to boost your product and service to the wider web community, you can visit our Dewalist classified website – home to 31,000+ active users and 40,000+ active advertising so far. Check it out!

If you love this security article or any tech posts and you would like to receive an update of this article or our latest post, please sign up for the form below:

Newsletter signup

This is a newsletter for tech, creative, gadgets, games and crypto.

Please wait...

Thank you for sign up!




Valdy

About Author

Valdy founded Dewacorp.com, a helpdesk and IT Services provider that has taken care of nearly 40,000 customer service requests in the past 15 years - nearly 2,600 per year. He also created the growing Dewalist.com - a classified website that has close to 110,000 page views and 9,000+ user visits per month with 61,000+ yearly published ads and 47,000 active registered users. He blogs for the ever-growing Dewapost.com, a tech blog that gets around 20,000 impressions per month with 700 clicks and 10 average pages first impressions on Google Search. You can reach him on the Contact Us page, social media links below or Dewachat.com.

1 Comment

  1. TSQL: The Discovery

    29 June 2022

    […] As we consolidated all tech blogs into Dewapost website, we also post this blog into Dewapost.com and we reformat the content to suit within their […]

Comments are closed.

You may also like

Programming

SQL: Performance Tuning Query

Queries — Basic setup DBCC DROPCLEANBUFFERSDBCC FREEPROCCACHE SET STATISTICS IO ONSET STATISTICS TIME ON /* SELECT * FROM dbo.Categories*/ Sources
Programming

Notes: Road to Yii Framework

Apache2 Configuration on MAC Snow Leopard: /etc/apache2/httpd.conf “It worksP page is located under: /Library/WebServer/Documents/index.html.en To restart apache2 after changing: sudo apachectl