set ansi_nulls on的用法
指定在与 Null 值一起使用等于 (=) 和不等于 (<>) 比较运算符时采用符合 ISO 标准的行为。
当 SET ANSI_NULLS 为 ON 时,即使 column_name 中包含空值,使用 WHERE column_name = NULL 的 SELECT 语句仍返回零行。即使 column_name 中包含非空值,使用 WHERE column_name <> NULL 的 SELECT 语句仍会返回零行。
当 SET ANSI_NULLS 为 OFF 时,等于 (=) 和不等于 (<>) 比较运算符不遵守 ISO 标准。使用 WHERE column_name = NULL 的 SELECT 语句返回 column_name 中包含空值的行。使用 WHERE column_name <> NULL 的 SELECT 语句返回列中包含非空值的行。
select * from qlei where sname is null
select * from qlei where sname is not null
结果如图:
set ansi_nulls on
select * from qlei where sname = null
select * from qlei where sname<>null
结果如图:
set ansi_nulls off
select * from qlei where sname = null
select * from qlei where sname<>null
结果如图:
6. SET QUOTED_IDENTIFIER的用法
当 SET QUOTED_IDENTIFIER 为 ON 时,标识符可以由双引号分隔,而文字必须由单引号分隔。当 SET QUOTED_IDENTIFIER 为 OFF 时,标识符不可加引号,且必须符合所有 Transact-SQL 标识符规则。在默认情况下,SET QUOTED_IDENTIFIER 为ON
set quoted_identifier on
select * into "user" from qlei--user为系统关键字如果直接使用会报错
select * from "user" where sno='990028'
select * from [user] where sno='990028'—-单引号变成双引号报错
结果如图:
set quoted_identifier off
select * from user where sno='990028'--这样写报错
select * from [user] where sno='990028'
select * from [user] where sno="990028"
结果如图:
- 大小: 7.5 KB
- 大小: 31.5 KB
- 大小: 31.8 KB
- 大小: 8.9 KB
分享到:
相关推荐
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO ALTER PROCEDURE test @From varchar(100)="zhang.zhanling@itgemini.net" , @To varchar(100)="zhang.zhanling@itgemini.net" ,@eng varchar(1000)=" ", ...
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[stuinf]( [name] [nchar](20) NOT NULL, [telephone] [nchar](50) NULL, [mobilepho] [nchar](50) NULL, [qq] [nchar](50) NULL, ...
例如,`SET ANSI_NULLS ON/OFF` 控制是否允许在WHERE子句中使用NULL值。`SET QUOTED_IDENTIFIER ON/OFF` 则影响标识符(如表名或列名)是否需要引号包裹。 3. **SQL SET ConnectAttr**:在某些数据库系统中,如...
SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Param_City]( [id] [int] IDENTITY(1,1) NOT NULL, [parentid] [int] NULL, [City] [varchar](250) NULL, [Create_id] [int] NULL, ...
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[diaryclass]( [id] [int] IDENTITY(1,1) NOT NULL, [classname] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK_...
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[gbook_class]( [id] [int] IDENTITY(1,1) NOT NULL, [classname] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK_gbook...
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Student]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NULL, [Age] [int] NULL, [Grade] [nvarchar](50) NULL, [Sex] ...
ALTER DATABASE [MyHotel] SET QUOTED_IDENTIFIER OFF GO ALTER DATABASE [MyHotel] SET RECURSIVE_TRIGGERS OFF GO ALTER DATABASE [MyHotel] SET ENABLE_BROKER GO ALTER DATABASE [MyHotel] SET AUTO_UPDATE_...
exec sp_dboption N'My_vehicle', N'quoted identifier', N'false' GO exec sp_dboption N'My_vehicle', N'ANSI warnings', N'false' GO exec sp_dboption N'My_vehicle', N'auto create statistics', N'true' GO ...
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uMessage]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[uMessage]( [id...
Extjs动态加载树,首先在数据库里面设计存放树信息的表 代码如下: USE [KimiExtjs] GO /****** 对象: Table [dbo].[Trees] 脚本日期: 04/08/2010 22:12:25 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON ...
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Book] ( [id] [int] NOT NULL, [name] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL, [password] ...
整理了一下SQL Server里面可能经常会用到的日期格式转换方法,整合一个函数来处理。 调用: select dbo.func_Print_DateFormat...SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /* 日期格式处理 日期:2015-8-28 1
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO --创建分页存储过程 CREATE PROCEDURE [dbo].[pro_GetPagedData] @pageIndex INT,--输入参数,页号 @pageSize INT,--输入参数,每页容量 @rowCount INT OUTPUT...
参考网址 //www.jb51.net/article/29551.htm 代码如下: SELECT [StartDate] FROM [dbo].[udf_Week](2012,2012) ... 代码如下: udf_StartDateOfFirstWeek SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FU
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[CancelOrderBySystem] AS BEGIN declare /*声明变量*/ @Status varchar(100), –状态 @TimeNow datetime, –当前时间 @...
文件:.wmv;大小:19,535KB;长度:00:26:39。... 就此bug对此函数修改如下: 代码如下: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER FUNCTION [dbo].[udf_Week] ( @StartYear INT, @EndYear
代码如下: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER FUNCTION [dbo].[udf_OrderLimitSize] ( @Ov NVARCHAR(30) ) RETURNS decimal(18,6) AS BEGIN –如果长度少于等于2的数值为返回NULL IF (LEN(@...
代码如下: CalNumOfChtInStr SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO — ============================================= — Author: Insus.NET — Create date: 2012-02-23 — Description: Calculate ...