The (nocount/ansi_nulls) option in SQL Server

Source: Internet
Author: User

1 Nocount Options

When SET NOCOUNT is on, no count is returned.
When SET NOCOUNT is OFF, the count is returned.

eg

if object_id(N'table_test'N'U') is  not NULLDrop Tabletable_testGoCREATE TABLETable_test (IDINT, nameVARCHAR( -))GoINSERT  intoTable_testVALUES(1,'xiaoming'),(2,NULL)GoSETNOCOUNT onSELECT *  fromtable_testGO


SET NOCOUNT Offselect * from Table_testgo

2 ANSI_NULLS Options

When SET Ansi_nulls is on,
SELECT statements that use WHERE column_name = NULL still return 0 rows, even if the column_name contains null values.

When SET Ansi_nulls is OFF,

Use the WHERE COLUMN_NAME = null SELECT statement to return rows that contain null values in column_name.

eg

SETAnsi_nulls on SELECT TOP  - *  fromTable_testWHEREName= NULL GoSETAnsi_nullsoff SELECT TOP  - *  fromTable_testWHEREName= NULL Go

The (nocount/ansi_nulls) option in SQL Server

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.