Functions of N 'xx' in SQL

Source: Internet
Author: User

Sometimes, we can see statements similar to the following in SQL statements:

Select O. ID, U. name owner, O. name, O. type from XXX. DBO. sysobjects o left join XXX. DBO. sysusers U on O. uid = u. UID where (O. type = n 'U' or O. type = n's 'or O. type = n 'V') order by O. name

Select O. ID, U. name owner, O. name, O. type from XXX. DBO. sysobjects o left join XXX. DBO. sysusers U on O. uid = u. UID where (O. type = 'U' or O. type = 's' or O. type = 'V') order by O. name

The running results of the preceding two statements may be identical. Note that N is before the character in the first statement. What does n mean?

The role of N is to ensure that the subsequent characters are considered Unicode-encoded.

"The N stands for national-the N converts the varchar to a nvarchar, which is used to store Unicode data, which is used to store multilingual data in your database tables. even simple translation:

N represents the national character. It can convert a character of the varchar type to a character of the nvarchar type and is used to store Unicode data. It is used to store multilingual data in database tables.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.