You are currently viewing How To Find Square Root Of A Number in SQL Server

How To Find Square Root Of A Number in SQL Server

How To Find Square Root Of A Number in SQL Server

SQRT() Function return the square root of a given number. It takes only one positive integer as an argument and return a positive integer. An argument can be a positive integer or a fraction. Square root of a negative number can not be calculated.

Find the Square Root of an integer

In the below query we will find the square root of 16.

SELECT SQRT(16) AS SquareRootOfNumber
Square root of a number

Find the Square Root of a fraction

In the below query we will find the square root of a fraction 81/9.

SELECT SQRT(81/9) AS SquareRootOfFraction
Square root of a fraction

Find the Square Root of a decimal number

In the below query we will find the square root of a decimal number 25.25.

SELECT SQRT(25.25) AS SquareRootOfDecimal

Find the Square Root of a number using variable

In the below query we will find the square root of a number 49 by declaring a variable.

DECLARE @Num INT
SET @Num = 49
SELECT SQRT(@Num) AS SquareOfNum
Square root using variable

Recommended Readings