Sqlserver: Set ansi_nulls

Source: Internet
Author: User

Specifies the standard SQL-92 behavior for equal to (=) and not equal to (<>) Comparison operators when used with null values.

When set ansi_nulls is onColumn_nameContains null values, whereColumn_name=NullThe SELECT statement of returns zero rows. Even ifColumn_nameContains non-null values, whereColumn_name<>NullThe SELECT statement will still return zero rows.

When set ansi_nulls is off, equal to (=) and not equal to (<>) Comparison operators do not comply with SQL-92 standards. Use whereColumn_name=NullReturns the SELECT statementColumn_nameContains null rows. Use whereColumn_name<>NullThe SELECT statement of returns rows that contain non-null values. In addition, use whereColumn_name<>Xyz_valueReturns allXyz_valueIt is not a null row.

When set ansi_nulls is on, all Null Value Comparison values are unknown.

When set ansi_nulls is off, if the data value is null, the comparison of all data null values is true. If set ansi_nulls is not specifiedAnsi_nullsOption settings.

Set ansi_nulls on affects the comparison only when a compare operand is a null variable or a text is null.

If both sides of the comparison are columns or composite expressions, this setting will not affect the comparison.

To make the script run as expectedAnsi_nullsHow to Set Database options or set ansi_nulls and use is null and is not null in comparisons that may contain null values.

Set ansi_nulls to on when executing a distributed query.

Set ansi_nulls must also be on when you create or change an index for a calculated column or index view.

If set ansi_nulls is off, the CREATE, update, insert, and delete statements for the table (including the index of the calculation column or index view) will fail. SQL Server Returns an error message that lists all set options that violate the required values. In addition, if set ansi_nulls is off when the SELECT statement is executed, SQL Server ignores the index value of the calculated column or view and parses the selection operation, it is like a table or view does not have such an index.

RequiredPublicRole member identity

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.