insert into txt select ArticleID,Content from PE_Article where ArticleID not in (select ArticleID,Content from PE_Article where ArticleID>=1165 and ArticleID<=1674)我想把在一个表查询到的内容,插入另外一个表里面,但是出现错误..
1)当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表 'txt' 中为标识列指定显式值。
2)当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。

解决方案 »

  1.   

    set identity_insert txt on
    insert into txt(显示地把要插入的字段名称写出来)
    select ArticleID,Content from PE_Article where ArticleID not in (select ArticleID from PE_Article where ArticleID>=1165 and ArticleID<=1674)
    set identity_insert txt off
      

  2.   

    第一个错误是因为你的txt表中有一个“自增”字段.
    第二个错误是因为你的“select”语句中的not in 部分有错误.
      

  3.   

    当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。
    这个问题没有解决啊...在线等...
      

  4.   

    估计你的意思是取not in (select ArticleID from --,Content 去掉了
      

  5.   

    set identity_insert txt on
    insert into txt(Content)
    select Content from PE_Article where ArticleID not in (select Content from PE_Article where ArticleID>=1165 and ArticleID<=1674)
    set identity_insert txt off我的Content为ntext文本.
    服务器: 消息 279,级别 16,状态 3,行 2
    在这一子查询或聚合表达式中,text、ntext 和 image 数据类型无效。
    服务器: 消息 306,级别 16,状态 1,行 2
    不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
      

  6.   

    set identity_insert txt on
    insert into txt(Content)
    select Content from PE_Article where ArticleID not in (select ArticleID from PE_Article where ArticleID>=1165 and ArticleID<=1674)
    set identity_insert txt off--子查询中应该是ArticleID,不是Content
      

  7.   

    ArticleID not in (select ArticleID,Content from PE_Article where ArticleID>=1165 and ArticleID<=1674)这儿有问题。,ArticleID not in() 当然只能是一个ArticleID 的集合,
    所以子查询里面也只能是 ArticleID not in (select ArticleID  from PE_Article where ArticleID>=1165 and ArticleID<=1674)