Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL Server
Expertise: Beginner
Jun 25, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Arithmetic functions in SQL

How do you create or access arithmetic functions like INT, MOD, or SQRT for use in Microsoft SQL Server?

SQL Server supports math functions including SQRT, CEIL, FLOOR, and ROUND. As far as MOD goes, SQL Server supports the use of % instead of a MOD function. For example,

SELECT 3 % 2
results in 1.

When it comes to creating other functions that you can call from SQL Server, there are a couple of options:

  • You could create the function manually in a stored procedure using SQL.
  • You could create a DLL in VB or any other language that takes the two numbers and returns the remainder, and call it using the OLE automation stored procedures.
  • You could create an extended stored procedure in C++ and register it in SQL Server.
Hope this helps.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date