insert 数据库B.dbo.表B(字段列表0 select 要导入的字段列表 from 数据库A.dbo.表A

解决方案 »

  1.   

    insert target table select * from source table
      

  2.   

    to zjcxcinsert A.dbo.a(e,f,g)
    select (h,i,j)
    from B.dbo.b提示:Server: Msg 2627, Level 14, State 1, Line 1
    Violation of PRIMARY KEY constraint 'PK_SUPPLY'. Cannot insert duplicate key in object 'SUPPLY'.
    The statement has been terminated.其中A.dbo.a的PRIMARY KEY 为e,这是怎么回事?
      

  3.   

    insert into OpenDateSource('SQLoledb','data source=服務器B;user id=用戶名;password=12345').數據庫B.dbo.表B (col1,col2,col3....) select (col1,col2,col3....) from 表A where.....
    A表與B表的字段數要一樣多。
      

  4.   

    你要将PRIMARY KEY或IDENTITY限制去掉。
      

  5.   

    insert A.dbo.a(e,f,g)
    select (h,i,j)
    from B.dbo.b b
    where not exists(select * from A.dbo.a where e=b.h)  --忽略主键重复的记录
      

  6.   

    to zjcxc
    对于insert A.dbo.a(e,f,g)
    select (h,i,j)
    from B.dbo.b b
    where not exists(select * from A.dbo.a where e=b.h)  --忽略主键重复的记录提示:Server: Msg 446, Level 16, State 9, Line 1
    Cannot resolve collation conflict for equal to operation.现在A.dbo.a中只有一条数据,是用insert A.dbo.a(e,f,g)
                                   select (h,i,j)
                                   from B.dbo.b
                                   where h='001' 导过来的