关键字“OF”附近的语法错误(带有标识列的填充表)

时间:2012-08-19 17:18:38

标签: sql-server-2008 fill

我制作了三张桌子:

    CREATE TABLE country_ (
    id_country  int NOT NULL IDENTITY(219,1),
    oid int NOT NULL,
    country_name_ru varchar(50) NOT NULL,
    country_name_en varchar(50) NOT NULL, 
    PRIMARY KEY  (id_country) 
  ) 


    CREATE TABLE region_ (
    id_region int NOT NULL IDENTITY(1612,1),
    id_country int NOT NULL FOREIGN KEY REFERENCES country_(id_country),
    oid int  NOT NULL,
    region_name_ru varchar(255) NOT NULL,
    region_name_en varchar(255) NOT NULL,
    PRIMARY KEY  (id_region) 
 ) 

    CREATE TABLE city_ (
    id_city int NOT NULL  IDENTITY(17590,1),
    id_region int NOT NULL FOREIGN KEY REFERENCES region_(id_region),
    id_country int NOT NULL FOREIGN KEY REFERENCES country_(id_country),
    oid int NOT NULL,
    city_name_ru varchar(255) NOT NULL,
    city_name_en varchar(255) NOT NULL,
    PRIMARY KEY  (id_city) 
 ) 

然后我试着填写它们:

    SET IDENTITY_INSERT country_  ON

    INSERT INTO country_  ( id_country,oid,country_name_ru,country_name_en) VALUES       (1,   3159, 'Россия', 'Russia');

    SET IDENTITY_INSERT country_  OF

这样我填写了region_和city_表,但我有三个错误:

  

关键字“OF”附近的语法错误。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

关闭

SET IDENTITY_INSERT country_  OFF

您可以阅读此声明here

如您所见,语法包括OFF

SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }