Skip to main content

SQL Buil-In Functions, String Functions,NCHAR

Returns the Unicode character with the specified integer code, as defined by the Unicode standard

Syntax



NCHAR ( integer_expression )
 

Arguments

integer_expression
Is a positive whole number from 0 through 65535. If a value outside this range is specified, NULL is returned.
 

Return Types

nchar

Examples

A. Using NCHAR and UNICODE

The following example uses the UNICODE and NCHAR functions to print the UNICODE value and the NCHAR (Unicode character) of the second character of the København character string, and to print the actual second character, ø.
 DECLARE @nstring nchar(8)
SET @nstring = N'København'
SELECT UNICODE(SUBSTRING(@nstring, 2, 1)),
   NCHAR(UNICODE(SUBSTRING(@nstring, 2, 1)))
GO


Here is the result set.
 ----------- -
248         ø(1 row(s) affected)

B. Using SUBSTRING, UNICODE, CONVERT, and NCHAR

 

The following example uses the SUBSTRING, UNICODE, CONVERT, and NCHAR functions to print the character number, the Unicode character, and the UNICODE value of each character in the string København.
 -- The @position variable holds the position of the character currently
-- being processed. The @nstring variable is the Unicode character
-- string to process.
DECLARE @position int, @nstring nchar(9)
-- Initialize the current position variable to the first character in
-- the string.
SET @position = 1
-- Initialize the character string variable to the string to process.
-- Notice that there is an N before the start of the string. This
-- indicates that the data following the N is Unicode data.
SET @nstring = N'København'
-- Print the character number of the position of the string you are at,
-- the actual Unicode character you are processing, and the UNICODE
-- value for this particular character.
PRINT 'Character #' + ' ' + 'Unicode Character' + ' ' + 'UNICODE Value'
WHILE @position <= DATALENGTH(@nstring)
   BEGIN
   SELECT @position,
      NCHAR(UNICODE(SUBSTRING(@nstring, @position, 1))),
      CONVERT(NCHAR(17), SUBSTRING(@nstring, @position, 1)),
      UNICODE(SUBSTRING(@nstring, @position, 1))
   SELECT @position = @position + 1
   END
GO

Here is the result set.

Character # Unicode Character UNICODE Value
                                              
----------- ---- ----------------- -----------
1           K    K                 75

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
2           ø    ø                 248

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
3           b    b                 98

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
4           e    e                 101

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
5           n    n                 110

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
6           h    h                 104

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
7           a    a                 97

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
8           v    v                 118

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
9           n    n                 110

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
10          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
11          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
12          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
13          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
14          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
15          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
16          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
17          NULL                   NULL

(1 row(s) affected)

                                              
----------- ---- ----------------- -----------
18          NULL                   NULL

(1 row(s) affected)
Reference:: SQL Online BOOKS

Comments

Popular posts from this blog

PHP DATABASE CONNECTION

//connecting to db $conn = mysql_connect("localhost","peter","abc123"); if (!$conn) { die('Could not connect: ' . mysql_error()); } // some code mysql_close($conn); // closing connection //query db $data=$conn->query("SELECT * FROM myTable "); foreach($data as $row) { print_r($row); }

CUSTOM WHERE CLASS IN SUGARCRM DASHLETS

How to add custom where class in sugar dashlets??? for example if you want to see top opportunities dashlet containing only filtered opportunities on some condition then you can do this as below require_once(‘modules/Opportunities/Dashlets/MyOpportunitiesDashlet/MyOpportunitiesDashlet.php’); class MyOpportunitiesCustomDashlet extends MyOpportunitiesDashlet { function MyOpportunitiesCustomDashlet($id, $def = null) { global $current_user, $app_strings, $dashletData; require(‘modules/Opportunities/Dashlets/MyOpportunitiesDashlet/MyOpportunitiesDashlet.data.php’); parent::MyOpportunitiesDashlet($id, $def); } function process($lvsParams = array()) { $lvsParams = array( ‘custom_select’ => ”, ‘custom_from’ => ”, ‘custom_where’ => ‘ AND opportunities.sales_stage=\’Qualification\”, ‘distinct’ => true ); parent::process($lvsParams); } } these codes are only hints, you should know where these piece of codes should be placed to be working..

AJAX BANNED MODULES

In SugarCRM if you want to ban ajax only for particular modules then go to your config_override.php file and add this code $sugar_config['addAjaxBannedModules'][] = “KReports”; //disable ajaxgui for specific module in config override. Now you have done