Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use TRUNC function in SQL server 2012, as am getting 'TRUNC' is not a recognized built-in function name.'?

How to use TRUNC function in SQL Server 2012, as I am getting an error:

'TRUNC' is not a recognized built-in function name.'

when I execute the statement

SELECT TRUNC(30.95, 1)

in SQL Server 2012

http://msdn.microsoft.com/en-us/library/ee634907.aspx

like image 454
Princess S Avatar asked Dec 27 '22 01:12

Princess S


2 Answers

It is a DAX function, not a built in SQL function. It looks like those would be for use in Excel.

http://technet.microsoft.com/en-us/library/gg399181.aspx

The built in function for SQL Server 2012 are here:

http://msdn.microsoft.com/en-us/library/ms177516.aspx

like image 184
user2517183 Avatar answered Dec 28 '22 16:12

user2517183


ROUND ( 30.95 , 1 , 1 )

When the third parameter != 0 it truncates rather than rounds

http://msdn.microsoft.com/en-us/library/ms175003(SQL.90).aspx

Thanks to https://stackoverflow.com/a/44093/44743

like image 21
recursive Avatar answered Dec 28 '22 16:12

recursive