GC_DevUser库中gc_department表
dp_id int
dp_parentid int
dp_name varchar(100)
dp_sort_seq int
 DevTrackerMy库中Organization表
Id int
Name nvarchar(50)
State bit
ParentId  int
OrgTypeId intdp_name与Name对应  dp_parentid与ParentId对应其他不用考虑

解决方案 »

  1.   

    晕,没说哪个转到哪个insert GC_DevUser..gc_department(dp_parentid,dp_name )
    select ParentId,Name from DevTrackerMy..Organizationor:
    insert DevTrackerMy..Organization( ParentId,Name)
    select dp_parentid,dp_name from GC_DevUser..gc_department
      

  2.   

    首先用户有权限:
    insert into DevTrackerMy.dbo.Organization(Id,Name,State,ParentId,OrgTypeId )
    select null,dp_name,null,dp_parentid,null from 
    GC_DevUser.dbo.gc_department
      

  3.   

    Msg 339, Level 16, State 1, Line 1
    DEFAULT or NULL are not allowed as explicit identity values.
      

  4.   

    从错误看,其他字段有非空而且没有default的你必须确定这些字段如何取值才能改好语句
      

  5.   

    如果随便取值,试下insert GC_DevUser..gc_department(dp_parentid,dp_name,dp_sort_seq )
    select ParentId,Name,0 from DevTrackerMy..Organization或者insert DevTrackerMy..Organization( ParentId,Name,State,OrgTypeId)
    select dp_parentid,dp_name,0,0 from GC_DevUser..gc_department
      

  6.   

    Msg 339, Level 16, State 1, Line 1
    DEFAULT or NULL are not allowed as explicit identity values
    -----------------說明Organization表的Id列是自增列
    試試這個:
    insert DevTrackerMy.dbo.Organization
     select dp_name, null, dp_parentid, null
     from GC_DevUser.dbo.gc_department
      

  7.   

    Msg 2627, Level 14, State 1, Line 2
    Violation of PRIMARY KEY constraint 'PK__Organization__65370702'. Cannot insert duplicate key in object 'dbo.Organization'.
    这个是什么问题?
      

  8.   

    Organization表是拿哪些字段做主鍵的,樓主知道嗎
      

  9.   

    可以考虑用SSIS来实现!可以实现不同的数据库之间的数据的传递!
      

  10.   

    我是这么写的
    Set Identity_Insert DevTrackerMy.dbo.Organization On
    insert into DevTrackerMy.dbo.Organization(Id,Name,Describe,State,ParentId,Email,OrgTypeId )
    select dp_id,dp_name,'1','False',dp_parentid,'1','1' from 
    GC_DevUser.dbo.gc_department
    Set Identity_Insert DevTrackerMy.dbo.Organization OFF把主见和自增去掉后报
    Msg 8106, Level 16, State 1, Line 1
    Table 'DevTrackerMy.dbo.Organization' does not have the identity property. Cannot perform SET operation.
      

  11.   

    既然Id是自增列並且是主鍵,那insert的時候就不要出現這一列了insert DevTrackerMy.dbo.Organization(Name,Describe,State,ParentId,Email,OrgTypeId)
     select dp_name,'1','False',dp_parentid,'1','1' from GC_DevUser.dbo.gc_department
      

  12.   

    如果是你写的这样就抱错误
    Msg 545, Level 16, State 1, Line 2
    Explicit value must be specified for identity column in table 'Organization' either when IDENTITY_INSERT is set to ON or when a replication user is inserting into a NOT FOR REPLICATION identity column.
    如果我把自增去掉  如何给Id负个值 就是直接拷贝
      

  13.   

     .
    采用“..",DTS.
    还有用户权限问题。
      

  14.   

    insert ...select应该可以解决,id是自增的不用管他
      

  15.   

    如果用SSIS,能不能做到:根据主键,已存在的做update,不存在的做insert?