{"id":3426,"date":"2018-11-05T19:43:28","date_gmt":"2018-11-06T02:43:28","guid":{"rendered":"https:\/\/database.guide\/?p=3426"},"modified":"2019-11-19T22:57:08","modified_gmt":"2019-11-20T05:57:08","slug":"tan-examples-in-sql-server","status":"publish","type":"post","link":"https:\/\/database.guide\/tan-examples-in-sql-server\/","title":{"rendered":"TAN() Examples in SQL Server"},"content":{"rendered":"<p>In\u00a0<a href=\"https:\/\/database.guide\/what-is-sql-server\/\">SQL Server<\/a>, the <code>TAN()<\/code> function returns the tangent of the input expression. <\/p>\n<p>You provide the value as an argument when calling the function.<\/p>\n<p><!--more--><\/p>\n<h2>Syntax<\/h2>\n<p>The syntax goes like this:<\/p>\n<pre>TAN ( float_expression ) \r\n<\/pre>\n<p>Where <em>float_expression<\/em> is an expression of type float or of a type that can be implicitly converted to float, interpreted as number of radians.<\/p>\n<h2>Example 1 &#8211; Basic Usage<\/h2>\n<p>Here&#8217;s a basic example that returns the tangent of a single value.<\/p>\n<pre>SELECT TAN(1) Result;\r\n<\/pre>\n<p>Result:<\/p>\n<pre>+-----------------+\r\n| Result          |\r\n|-----------------|\r\n| 1.5574077246549 |\r\n+-----------------+\r\n<\/pre>\n<p>And with another value.<\/p>\n<pre>SELECT TAN(2.3) Result;\r\n<\/pre>\n<p>Result:<\/p>\n<pre>+-------------------+\r\n| Result            |\r\n|-------------------|\r\n| -1.11921364173413 |\r\n+-------------------+\r\n<\/pre>\n<h2>Example 2 &#8211; Negative Value<\/h2>\n<p>Here we switch the previous value to negative value.<\/p>\n<pre>SELECT TAN(-2.3) Result;\r\n<\/pre>\n<p>Result:<\/p>\n<pre>+------------------+\r\n| Result           |\r\n|------------------|\r\n| 1.11921364173413 |\r\n+------------------+\r\n<\/pre>\n<h2>Example 3 &#8211; Expressions<\/h2>\n<p>You can also pass in expressions like this:<\/p>\n<pre>SELECT TAN(2.5 + 0.3) Result;\r\n<\/pre>\n<p>Result:<\/p>\n<pre>+--------------------+\r\n| Result             |\r\n|--------------------|\r\n| -0.355529831651176 |\r\n+--------------------+\r\n<\/pre>\n<h2>Example 4 &#8211; Passing in a Function<\/h2>\n<p>In this example I pass in the T-SQL <a href=\"https:\/\/database.guide\/pi-examples-in-sql-server\/\"><code>PI()<\/code><\/a> function as the argument.<\/p>\n<pre>SELECT \r\n  PI() 'PI',\r\n  TAN(PI()) 'Tangent of PI';\r\n<\/pre>\n<p>Result:<\/p>\n<pre>+------------------+-----------------------+\r\n| PI               | Tangent of PI         |\r\n|------------------+-----------------------|\r\n| 3.14159265358979 | -1.22464679914735E-16 |\r\n+------------------+-----------------------+\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In\u00a0SQL Server, the TAN() function returns the tangent of the input expression. You provide the value as an argument when calling the function.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,5],"tags":[93,70,77,61],"class_list":["post-3426","post","type-post","status-publish","format-standard","hentry","category-sql","category-sql-server","tag-functions","tag-mathematical-functions","tag-mssql","tag-t-sql"],"_links":{"self":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/3426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/comments?post=3426"}],"version-history":[{"count":3,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/3426\/revisions"}],"predecessor-version":[{"id":3429,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/3426\/revisions\/3429"}],"wp:attachment":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/media?parent=3426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/categories?post=3426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/tags?post=3426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}