Sunday, April 23, 2017

SQRT() in SQL Server


SQL SQRT() function is used to return the square root of the numeric expression.. NULL values are not considered. SQRT() does not work on non-numeric columns such as text, it also does not work on negative value passed as an argument.


Syntax:

     
            SELECT SQRT(numeric_expression float)
           

numeric_expression is the numeric value of which square root is to be calculated.



Example 1:
SQRT() on numeric column.

SELECT * FROM TempEmployeePayHistory




SELECT Rate, SQRT(Rate) FROM TempEmployeePayHistory



Example 2:
SQRT() on column with NULL values.

          SELECT * FROM TempEmployeePayHistory



SELECT Rate, SQRT(Rate) FROM TempEmployeePayHistory



Example 3:
SQRT() on text column.

          SELECT * FROM DatabaseLog



          SELECT [Event], SQRT([Event]) FROM DatabaseLog



Example 4:
SQRT() on negative value.



Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: