Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    47

    Unanswered: delete duplicate rows

    Suppose that we have the following rows in a MSSQL table :


    1 administrateur 1 NULL NULL
    2 administrateur 2 NULL NULL
    1 administrateur 1 NULL NULL
    2 administrateur 2 NULL NULL



    How to remove duplicates (leave only the 2 first rows) ?

  2. #2
    Join Date
    Dec 2004
    Posts
    47
    --drop table #MyTable
    --drop table #MyTable1
    create table #MyTable (x int, y varchar (50), z int)
    create table #MyTable1 (x int, y varchar (50), z int)
    insert into #MyTable values (1,'administrateur',1)
    insert into #MyTable values (2,'administrateur',2)
    insert into #MyTable values (1,'administrateur',1)
    insert into #MyTable values (2,'administrateur',2)


    INSERT INTO #MyTable1 select distinct * from #MyTable

    SELECT * FROM #MyTable1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •