What does T-SQL string mean by adding N before?

Source: Internet
Author: User

What is the meaning of adding N before the T-SQL string, such as select @ status = N 'stopped ', then why should N be added before the string stopped? In addition, we find that N is not affected in some places, and N must be added in some places. Here, www.2cto.com N indicates Unicode, which is a double byte character. For Western characters, one byte is enough. For Eastern characters, two bytes are required for storage. To ensure consistency, standardization, convenience, and compatibility, Unicode requires that Spanish characters are also stored in two bytes. That is to say, adding N indicates that the string is stored in Unicode mode. But what is the reason for the same addition and not addition? This is caused by automatic conversion. For example, declare @ status nvarchar (20) select @ status = n' stopped 'select @ status = 'stopped '. In fact, the values of the preceding two statements are the same, because the variable type is nvarchar (Unicode type ). In some cases (for example, the sp_executesql parameter) cannot be automatically converted, so N is required.

Related Article

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.