Skip to content
Related Articles

Related Articles

Improve Article

PI() Function in SQL Server

  • Last Updated : 29 Dec, 2020

PI() function :

This function in SQL Server is used to return the constant float value of math Pi. The default number of decimal places displayed is seven, but SQL Server uses the full double-precision value internally.

Features :

  • This function is used to get the value of pi.
  • This function does not accept any parameters.
  • Any types of mathematical operations can be done with this function such as addition, multiplication etc.

Syntax :

PI()

Parameter :



This method does not accept any parameter.

Returns :

It returns the Pi value.

Example-1 :

Getting the default value of pi.

SELECT PI();

Output :

3.1415926535897931

Example-2 :

Using PI() function with addition of value of 2 taken as a variable and getting value of pi after addition of 2.

DECLARE @Parameter_Value INT;
SET @Parameter_Value = 2;
SELECT PI() + @Parameter_Value;

Output :

5.1415926535897931

Example-3 :

Getting value of pi after subtracting 1.

SELECT PI() - 1;

Output :

2.1415926535897931

Example-4 :

Getting the default value of pi up to next 3 decimal places.

SELECT ROUND(PI(), 3) As New;

Output :

3.1419999999999

Application :

This function is used to return the Pi value.

My Personal Notes arrow_drop_up
Recommended Articles
Page :