{"id":6250,"date":"2013-09-01T00:00:53","date_gmt":"2013-09-01T00:00:53","guid":{"rendered":"http:\/\/craftydba.com\/?p=6250"},"modified":"2016-04-21T21:15:21","modified_gmt":"2016-04-21T21:15:21","slug":"math-functions","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=6250","title":{"rendered":"Math Functions &#8211; ABS()"},"content":{"rendered":"<p>I am going to start a series of short articles or tidbits on Transaction SQL <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms177516.aspx\">math functions<\/a>.  Most, if not all, of these functions have been in the product before the release of SQL Server 2005.  <\/p>\n<p>I am very proud of my daughter making the advance math class in sixth grade.  I am dedicating these blogs to her hard class work and love of the subject.<\/p>\n<p>I will be exploring the absolute values, <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms189800.aspx\">ABS()<\/a> function today.  This function takes a expression in either exact numeric or approximate numeric form and returns the positive value.<\/p>\n<p>The example below tests the ABS() function with three different inputs:  negative numbers, positive numbers and a null value.<\/p>\n<pre class=\"lang:TSQL theme:familiar mark:1,2-3\" title=\"abs() - math functions\">\r\n--\r\n--  Absolute value (ABS) Function\r\n--\r\n\r\n-- Absolute value of number (remove sign)\r\nSELECT \r\n    ABS(-10) AS NEGATIVE, \r\n    ABS(10) AS POSITVE, \r\n    ABS(NULL) as UNKNOWN;\r\nGO\r\n\r\n<\/pre>\n<\/p>\n<p>The output from the test is listed below.<\/p>\n<pre class=\"lang:TSQL theme:epicgeeks\" title=\"output\">\r\noutput: \r\n\r\nNEGATIVE   POSITVE    UNKNOWN\r\n---------- ---------- ----------\r\n10         10         NULL\r\n\r\n<\/pre>\n<\/p>\n<p>In a nutshell, this function will return the positive value of any numeric expression.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am going to start a series of short articles or tidbits on Transaction SQL math functions. Most, if not all, of these functions have been in the product before the release of SQL Server 2005. I am very proud of my daughter making the advance math class in sixth grade. I am dedicating these blogs to her hard class work and love of the subject. I will be exploring the absolute values, ABS() function today. This function takes a expression in either exact numeric or approximate numeric form and&hellip;<\/p>\n","protected":false},"author":1,"featured_media":5430,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[814],"tags":[912,31,15,913,29],"class_list":["post-6250","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-very-short-articles","tag-abs","tag-database-developer","tag-john-f-miner-iii","tag-math-function","tag-tsql"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6250"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6250\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/media\/5430"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}