把目的表的主键约束去掉 ,先导入数据,然后对数据进行处理,去掉重复的数据--先定义表变量 @tmptable
DECLARE @tmptable 他变了(A int,B int,C int)
insert into @tmptable select distinct * from table1 
drop table
select * into table1 from @tmptable

解决方案 »

  1.   

    输入错了,拼音没转换过来,上面的 他变了 应该是 table把目的表的主键约束去掉   ,先导入数据,然后对数据进行处理,去掉重复的数据 --先定义表变量 @tmptable
    DECLARE @tmptable table(A int,B int,C int)
    insert into @tmptable select distinct * from table1 
    drop table
    select * into table1 from @tmptable
      

  2.   

    EXEC   master..xp_cmdshell   'bcp   "select   Ykchr..B01.B0105,Ykchr..B01.B0150,Ykchr..B01.B0160,Ykchr..B01.D0101, 
    Ykchr..B01.D0102,Ykchr..B01.D0103,Ykchr..B01.D0104,Ykchr..B01.D0105, 
    Ykchr..B01.D0106,Ykchr..B01.D0107,Ykchr..B01.D0108,Ykchr..B01.D0109, 
    Ykchr..B01.D010A,Ykchr..B01.D010B,Ykchr..B01.D010C,Ykchr..B01.D010D, 
    Ykchr..B01.D010E,Ykchr..B01.D010F,Ykchr..B01.D010G,Ykchr..B01.D010H, 
    Ykchr..B01.D010I,Ykchr..B01.D010J,Ykchr..B01.D010K,Ykchr..B01.D010L, 
    Ykchr..B01.D010M,Ykchr..B01.D010N, 
    Ykchr..B01.D010O,Ykchr..B01.D010P,Ykchr..B01.D010Q,Ykchr..B01.D010R,Ykchr..B38.D3801, 
    Ykchr..B38.D3802,Ykchr..B38.D3803,Ykchr..B38.D3804,Ykchr..B38.Ykchr..D3805, 
    Ykchr..B38.D3806,Ykchr..B38.D3807,Ykchr..B38.D3808,B38.Ykchr..D3809,B38.D380I, 
    Ykchr..B38.D380A,Ykchr..B38.D380B,Ykchr..B38.D380C,Ykchr..B38.D380D,Ykchr..B38.D380E, 
    Ykchr..B38.D380F,Ykchr..B38.D380G,Ykchr..B38.D380H,Ykchr..B41.D4101,Ykchr..B41.D4102, 
    Ykchr..B41.D4103,Ykchr..B41.D4104,Ykchr..B41.D4105,Ykchr..B41.D4106, 
    Ykchr..B41.D4107,Ykchr..B41.D4108,Ykchr..B41.D4109,Ykchr..B41.D410A,Ykchr..B41.D410B, 
    Ykchr..B41.D410C,Ykchr..B41.D410D,Ykchr..B41.D410E,Ykchr..B41.D410F,Ykchr..B41.D410G, 
    Ykchr..B41.D410H,Ykchr..B41.D410I,Ykchr..B35.D3501,Ykchr..B35.D3502, 
    Ykchr..B35.D3503,Ykchr..B35.D3504,Ykchr..B35.D3505,Ykchr..B35.D3506,Ykchr..B35.D3507, 
    Ykchr..B35.D3508,Ykchr..B35.D3509,Ykchr..B35.D350A,Ykchr..B35.D350B,Ykchr..B35.D350C, 
    Ykchr..B35.D350D,Ykchr..B35.D350E,Ykchr..B35.D350F,Ykchr..B35.D350G     
    from   Ykchr.dbo.B01   left   join   Ykchr.dbo.B38     on     Ykchr.dbo.B01.B0110=Ykchr.dbo.B38.B0110   left   join   Ykchr.dbo.B41     on     Ykchr..B01.B0110=Ykchr..B41.B0110   left   join   Ykchr..B35     on     Ykchr..B01.B0110=Ykchr..B35.B0110   
    where     Ykchr..B01.blag=0"   queryout   d:\hrpsoft.bpd   -c   -S"."   -U"sa"   -P""' 
      

  3.   

    楼上的大哥看一下,这一段代码有四张表组成B01,B35,B38,B41,其中B01是主表,其它的几张表是子表,通过bcp实用工具或者是其它的sql语句能把sqlserver2000中这几张表中数据导出到Access或几其它的数据文件中,生成一个比如hrp.bdp形式的或者是其它的数据文件,要并且可以从生成的导出的文件中导入,并且要能解决导入的时候,重复数据能够更新,要不然会提示主键索引重复?
      

  4.   

    select distinct * from table into table2.