Skip to content
Advertisement

Power function in T SQL

The following returns .81 as expected:

But this does not. Its return value is .8:

To have it return .81, I have to cast the input:

Why is a cast needed here? What am I missing?

Advertisement

Answer

The power function return type is dictated by the data type of the first parameter. Here, you’re giving it a decimal(1,1). As noted in the documentation, it’s returning a decimal(38,1).

You’ll get the result you want by either casting, as you’ve done, or by feeding the function differently.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement