Avoid Duplication-SqlServer 2000

Last post 10-25-2007 8:33 AM by Adriaan. 4 replies.
Page 1 of 1 (5 items)
Active Topics My Discussions Unanswered Sort Posts: Previous Next
  • 10-25-2007 5:05 AM

    • Jeena
    • Top 500 Contributor
    • Joined on 10-17-2007
    • India
    • Posts 30

    Avoid Duplication-SqlServer 2000

    Hi all,

    Im having two tables with 1 crores of record each. I want to avoid its duplication.But when im giving the query in query analyser for that.Its giving an error that,connection broken.Or sometimes in main window its giving time expired. What shoul i do for this. Kindly help me.

    Thank You.

    Jeen

  • 10-25-2007 5:40 AM In reply to

    Re: Avoid Duplication-SqlServer 2000

    When you say duplicate, is it just for one column or multiple columns?

    Madhivanan

    Failing to plan is Planning to fail
  • 10-25-2007 6:13 AM In reply to

    Re: Avoid Duplication-SqlServer 2000

    We need to see the query, and then the indexes on the table.

  • 10-25-2007 6:28 AM In reply to

    • Jeena
    • Top 500 Contributor
    • Joined on 10-17-2007
    • India
    • Posts 30

    Re: Avoid Duplication-SqlServer 2000

    Hi,

    Actually my table deals with mobileno: and the detail such as message,language,place,category.

    This records are used for sms purpose. So i need the distinct values of that tables.

    Eg: select distinct * into tablename from tablename

    But in this case i wil get mobileno duplication.ie,one person can send different mess.So it wil display

    mobileno   mess    lang   category

    12345        hai         eng     text

    12345        hi            eng      text

    My main problem is that its giving error connection broken,time expired etc.

    Wat is the solution for this?

    Help pls.

    Thank You

    Jeen

     

  • 10-25-2007 8:33 AM In reply to

    Re: Avoid Duplication-SqlServer 2000

    Do it in batches ... 

    SET ROWCOUNT 1000

    INSERT INTO target (column_list)
    SELECT DISTINCT .........
    FROM ........

    WHILE @@ROWCOUNT > 1
    BEGIN
       INSERT INTO target (column_list)
       SELECT DISTINCT .........
       FROM source
       WHERE NOT EXISTS (SELECT * FROM target WHERE target.key = source.key)
    END

    SET ROWCOUNT 0

Page 1 of 1 (5 items)
Active Topics   My Discussions    Unanswered Posts


© 2000 - 2007 vDerivatives Limited All Rights Reserved.