SET QUOTED_IDENTIFIER ON和SET ANSI_NULLS ON
distinct是sqlserver的标识符,如果想以distinct为表时,在QUOTED_IDENTIFIER为off的情况下,是不能创建表名为distinct的表的,因为在QUOTED_IDENTIFIER为off情况下,sqlserver的标识符是不允许加引号的,所以在
SET QUOTED_IDENTIFIER off的情况下,不管distinct加引号或不加引号或加双引号都是不可以的。
但是在 SET QUOTED_IDENTIFIER on 的情况下是可以把sqlserver的标识符加上双引号来创建以sqlserver标识符为表名的表,但是加单引号也是不可以的。
SET QUOTED_IDENTIFIER OFF GO -- An attempt to create a table with a reserved keyword as a name -- should fail. CREATE TABLE "select" ("identity" INT IDENTITY NOT NULL, "order" INT NOT NULL); GO SET QUOTED_IDENTIFIER ON; GO -- Will succeed. CREATE TABLE "select" ("identity" INT IDENTITY NOT NULL, "order" INT NOT NULL); GO SELECT "identity","order" FROM "select" ORDER BY "order"; GO DROP TABLE "SELECT"; GO SET QUOTED_IDENTIFIER OFF; GO
SET ANSI_NULLS ON