Home > database >  [bailout] how to write ANSI_NULLS and ANSI_WARNINGS on the trigger
[bailout] how to write ANSI_NULLS and ANSI_WARNINGS on the trigger

Time:09-30

I write a statement on the trigger is as follows:
The SET ANSI_NULLS ON
The SET ANSI_WARNINGS ON
GO
CREATE the TRIGGER DO_INSERT ON SC_DO_TEMP
FOR the INSERT
AS
.
GO
When I open the trigger a look at it again after finished the execution automatically converted into the following statement:
The SET QUOTED_IDENTIFIER OFF
GO
The SET ANSI_NULLS ON
GO
ALTER the TRIGGER DO_INSERT ON SC_DO_TEMP
FOR the INSERT
AS
.
Please everybody to give directions, there are no other way, (in order to realize the function is to write data on SERVER1 is another to pour directly by the trigger on SERVER2)
In not out I will likely be company T away
Save me ~ ~ ~ the poor man ah ~ ~ ~ ~

CodePudding user response:

In front of the first to understand the meaning of that a few words, it is good to do,
I estimate that is caused by the trigger code below you,
First try to write one of the most simple,

http://msdn.microsoft.com/zh-cn/library/ms188048.aspx

The SET ANSI_NULLS (Transact - SQL)

When the SET ANSI_NULLS to ON, even if column_name contains a NULL value, use the WHERE column_name=NULL SELECT statement returns a zero line still, even if column_name contain NULL values, using the WHERE column_name & lt;> NULL SELECT statement will return zero line,

When SET ANSI_NULLS to OFF, equals (=) and is not equal to (& lt;>) Comparison operators don't follow the ISO standard, use the WHERE column_name=NULL the SELECT statement returns column_name contains NULL line, use the WHERE column_name & lt;> The SELECT statement returns of NULL column contains the NULL line, in addition, use the WHERE column_name & lt;> XYZ_value SELECT statement returns all not for XYZ_value NULL line,

http://msdn.microsoft.com/zh-cn/library/ms190368.aspx

The SET ANSI_WARNINGS (Transact - SQL)

# set to ON, if the aggregate functions (like SUM, AVG, MAX, MIN, STDEV, STDEVP, VAR, VARP or COUNT) in null values, will generate a warning message, set to OFF, no warning,
# SET to ON, divided by zero error and arithmetic overflow error will lead to rollback statements, and generate an error message, SET to OFF, divided by zero error and arithmetic overflow error will lead to return null, if the character, Unicode or binary columns to try an INSERT or UPDATE operation, the new value in the column length exceeds the maximum size of the column, then will be divided by zero error and return null arithmetic overflow error, if the SET ANSI_WARNINGS to ON, then according to the ISO standard, will cancel the INSERT or UPDATE operation, the character of trailing blanks and binary column followed zero will be ignored, is SET to OFF, the size of the data will be tailored for the column, and the statement execution success,

http://msdn.microsoft.com/zh-cn/library/ms174393.aspx
The SET QUOTED_IDENTIFIER (Transact - SQL)
When the SET QUOTED_IDENTIFIER to ON, the identifier can be separated by double quotation marks, and the text must be by a single space, when SET QUOTED_IDENTIFIER to OFF, identifier is not quotes, and must comply with all rules, Transact - SQL identifier for more details, please refer to the identifier, text can be separated by a single or double quotation marks,

When the SET QUOTED_IDENTIFIER is ON (default), separated by double quotes all the string is interpreted as object identifier, therefore, quotes identifier don't conform to Transact - SQL identifier rules, they can be reserved keywords, and can contain Transact - SQL identifier, usually not allowed characters in delimited text string expression can't use double quotation marks, and must be enclosed in single quotation marks live text strings, if single quotes (') is part of the literal string, can be made up of two single quotation marks ("), said when the names of objects in the database using a reserved keyword, SET QUOTED_IDENTIFIER must to ON,

When SET QUOTED_IDENTIFIER to OFF, the expression of the text string can be separated by a single or double quotation marks, if the text string separated by double quotation marks, you can in the string contains an embedded single quotes, such as ellipsis,
  • Related