{"id":5373,"date":"2013-04-26T00:00:06","date_gmt":"2013-04-26T00:00:06","guid":{"rendered":"http:\/\/craftydba.com\/?p=5373"},"modified":"2017-10-08T16:19:21","modified_gmt":"2017-10-08T16:19:21","slug":"string-functions-unicode","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=5373","title":{"rendered":"String Functions &#8211; UNICODE()"},"content":{"rendered":"<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/04\/turquoise-yarn-md.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/04\/turquoise-yarn-md-150x150.png\" alt=\"\" title=\"turquoise-yarn-md\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-5158\" \/><\/a><br \/>\nI am going to write a series of very short articles or tidbits on Transaction SQL (TSQL) functions.  I will exploring the UNICODE() function today.<\/p>\n<p>Transaction SQL (TSQL) supports the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms180059.aspx\">UNICODE()<\/a> function that takes a NCHAR or NVARCHAR datatype as input and returns a INT datatype as output.  The output value corresponds to the unicode characters location in a chart.  This value can range from 0 to 65535.<\/p>\n<p>The following example returns the unicode value for a space which is a value of 32.<\/p>\n<pre class=\"lang:TSQL theme:familiar mark:1,2-3\" title=\"string functions - Unicode()\">\r\n-- A simple space\r\ndeclare @var_tmp1 nchar = ' ';\r\n\r\n-- Return ascii #\r\nselect unicode(@var_tmp1) as unicode_val;\r\n<\/pre>\n<pre class=\"lang:TSQL theme:epicgeeks\" title=\"output\">\r\noutput:\r\n\r\nunicode_val\r\n-----------\r\n32\r\n<\/pre>\n<\/p>\n<p>One thing to always worry about when using TSQL functions is how will it react with a UNKNOWN or NULL value?<\/p>\n<pre class=\"lang:TSQL theme:familiar mark:1,2-3\" title=\"string functions - Unicode()\">\r\n-- A unknown value\r\ndeclare @var_tmp2 nchar = NULL;\r\n\r\n-- Return ascii #\r\nselect ascii(@var_tmp2) as unicode_val;\r\n<\/pre>\n<pre class=\"lang:TSQL theme:epicgeeks\" title=\"output\">\r\noutput:\r\n\r\nunicode_val\r\n-----------\r\nNULL\r\n<\/pre>\n<\/p>\n<p>Next time, I will be exploring the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms180055.aspx\">UPPER()<\/a> function.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am going to write a series of very short articles or tidbits on Transaction SQL (TSQL) functions. I will exploring the UNICODE() function today. Transaction SQL (TSQL) supports the UNICODE() function that takes a NCHAR or NVARCHAR datatype as input and returns a INT datatype as output. The output value corresponds to the unicode characters location in a chart. This value can range from 0 to 65535. The following example returns the unicode value for a space which is a value of 32. &#8212; A simple space declare @var_tmp1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[814],"tags":[31,15,815,29,830],"class_list":["post-5373","post","type-post","status-publish","format-standard","hentry","category-very-short-articles","tag-database-developer","tag-john-f-miner-iii","tag-string-function","tag-tsql","tag-unicode"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/5373","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=5373"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/5373\/revisions"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}