比如表示这样的 表为TABLE
AUTOID   MA   MB  
1        100  101
2        200  200
3        220  220
4        301  305使用条件
如果MA的值<>MB的值
取出AUTOID的号码 ,并且重新排序到新表里 谢谢各位帮忙看一下~

解决方案 »

  1.   

    insert into newtable(id) select autoid from table where ma<>mb
      

  2.   

     
    declare @table table(autoid int,ma int,mb int)
    insert into @table
    select 1,100,101 union all
    select 2,200,200 union all
    select 3,220,220 union all
    select 4,301,305 
    select autoid into #新表 from @table where ma<>mb order by autoid
    select * from #新表 
      

  3.   

    DECLARE @TB TABLE(AUTOID INT,  MA INT,  MB INT)
    INSERT @TB
    SELECT 1,  100,  101 UNION ALL 
    SELECT 2,  200,  200 UNION ALL 
    SELECT 3,  220,  220 UNION ALL 
    SELECT 4,  301,  305SELECT AUTOID INTO NEWTABLE FROM @TB WHERE MA<>MB ORDER BY AUTOIDSELECT * FROM NEWTABLE DROP TABLE NEWTABLE
    /*
    AUTOID      
    ----------- 
    1
    4
    */
      

  4.   

    IF OBJECT_ID('TEMPDB..#')IS NOT NULL DROP TABLE #
    GO
    CREATE  TABLE #(AUTOID INT,  MA INT,  MB INT)
    INSERT #
    SELECT 1,  100,  101 UNION ALL 
    SELECT 2,  200,  200 UNION ALL 
    SELECT 3,  220,  220 UNION ALL 
    SELECT 4,  301,  305
    SELECT * INTO NEWTB FROM # WHERE MA!=MB  --生成新表NEWTB
    SELECT * FROM NEWTB--從新表中查詢
    /*(影響 2 個資料列)AUTOID      MA          MB          
    ----------- ----------- ----------- 
    1           100         101
    4           301         305(影響 2 個資料列)*/
      

  5.   

    Select AUTOID From [Table] Where MA<>MB
    找出不相同的记录Select * Into [TableNew] From [Table] Where MA<>MB
      

  6.   

    create TABLE #tb(AUTOID INT,MA INT,MB INT)
    INSERT #tb
    SELECT 1,100,101 UNION ALL 
    SELECT 2,200,200 UNION ALL 
    SELECT 3,220,220 UNION ALL 
    SELECT 4,301,305/*
    使用条件 
    如果MA的值 <>MB的值 
    取出AUTOID的号码 ,并且重新排序到新表里 谢谢各位帮忙看一下~
    */
    declare @aa table
    (
      AUTOID INT identity(1,1) primary key not null,
      MA INT,
      MB INT
    )
    insert into @aa select MA,MB from #tb t where t.MA<>t.MB
    select * from @aa
      

  7.   


    declare @table table(autoid int,ma int,mb int)
    insert into @table
    select 1,100,101 union all
    select 2,200,200 union all
    select 3,220,220 union all
    select 4,301,305 select autoid into #aa from @table where ma<>mb order by autoidselect * from #aadrop table #aa
    /*
    autoid
    -----------
    1
    4(2 行受影响)
    */
      

  8.   

    --这一句就实现了
    select AUTOID into newtable from table where MA<>MB
      

  9.   


    declare @t table(id int identity(1,1),qutoid int,ma int,mb int)insert @t(qutoid,ma,mb)
    select * from tb
    where ma<>mbselect * from @t
    id    autoid     ma     mb
    1 1 100 101
    2 4 301 305
      

  10.   

    insert into 新表(id) 
    select autoid from table where ma <>mb
      

  11.   


    select autoid from table where ma <> mb order by autoidselect autoid , px = (select count(1) from
    (
      select autoid from table where ma <> mb
    ) n where autoid < m.autoid
    ) + 1 from
    (
      select autoid from table where ma <> mb
    ) m
      

  12.   

    insert into 新表(id) 
    select autoid from table where ma <>mb 
      

  13.   

    select id=identity(int,1,1),AUTOID
    into newtable
    from oldtable
    where MA>MB or MA<MB
    order by AUTOID