第二个问题:
update 表 set
    city = '北京'
    where city = '四川'

解决方案 »

  1.   

    create table a
    (
    zjlbbm varchar(20) ,
    zjxm_name varchar(20)
    )
    goinsert into a(zjlbbm,zjxm_name) values('01','z01')
    insert into a(zjlbbm,zjxm_name) values('02','z01')
    insert into a(zjlbbm,zjxm_name) values('03','z01')
    insert into a(zjlbbm,zjxm_name) values('04','z02')
    insert into a(zjlbbm,zjxm_name) values('05','z03')
    insert into a(zjlbbm,zjxm_name) values('06','z03')select zjlbbm,id=identity(int,1,1),zjxm_name into #t from aselect * from #tdelete #t 
    from 
    ( select min(id) as id,zjxm_name from #t group by zjxm_name
    ) as no1
    where #t.zjxm_name = no1.zjxm_name 
    and #t.id > no1.id
    drop table #t
      

  2.   

    上面的方法是指表中没有primary key  的情况下处理的,如果表中有primary key 则不用使用临时表。
      

  3.   

    Select top 1 * into #tmp from TableName where FileName=bb
    delete TableName where  FileName=bb
    insert into tableName select * from #tmp