T-SQL – Using Power() function trims off the last 3 digits

A developer came to me with a problem regarding using POWER() function in his stored procedure. The result always comes out with the last 3 digits always cut off. His data type was decimal (30,10).

From MSDN, http://msdn.microsoft.com/en-us/library/ms174276(v=sql.105).aspx, the data type that use as paramater will the datatype of the result. 

From experience, what worked for me and i recommended this to our dev team, was to use float datatype as is, float.

Running the below will give you 2 different results.

declare @x as float = 0.8529703299
select power(@x, 2) as ‘Result’

declare @y as decimal(30,10) = ‘0.8529703299’
select power(@y, 2) as ‘Result’

So the float_expression should be just that, float datatype. I hope this helps someone out there too! 

Enjoy the new work week!






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


Inspired Global Storytelling

My Time to Travel

The travels of an old(er), solo, woman


The life of a data geek


Traveller Observer

The SQL Pro

(Ayman El-Ghazali - www.thesqlpro.com)

Meels on Wheels

Meels for breakfast, lunch and dinner.


Building A Business While Having A Life

Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, SQL Server BI, Data Modeling, SSAS Design, Power Pivot, Power BI, SSRS Advanced Design, Power BI, Dashboards & Visualization since 2009


Explaining the bits and bytes of SQL Server and Azure

Coding Tips

We are crazy about programming and we want to share our craziness with you!!!

SQL Studies

 Live, Learn, Share

Sql And Me

My Experiments with SQLServer

Dimitrios Kalemis

I am exactly like Jesus Christ: an atheist and anarchist against society and bad people with influence and power (judges, social workers, politicians, priests, and teachers).

Clint Huijbers' Blog

Senior Certified Microsoft BI Consultant

Blog of Many Useless Wonders

Where Uselessness Abounds!

Steve Spevack's Blog

IT Recruitment