inserting a list into a list that does not allow dupes

  • I have a table where the schema is as follows

    id bigtin identity(1,1)

    sn varchar(50)

    create primary key pk_id on table(id)

    create unique index ui_sn on table(sn)

    now if i use the import/export wizord, i would like to import a text file, but if there is a duplicate, i would like it to ignore it and keep going, In the import wizord, there is even a drop down to continue on error. But it always seems to stop as soon as it finds a duplicate.

    I rather not have to import the text file into a temp table, and then to a insert statment with a left outer join on itself and saying where table2.sn is null (one time i even ran this and it still says there was a duplicate!!! which is freaking impossible!!!) there were no other inserts going on to the table at the time!

    just to clear up my sql statment was

    insert into table1 t1 (select t2 from table2 left outer joing table1 t1 on t1.sn = t2.sn where t1 is null)

    did i do the statment wrong? i mean i ran this before successfully with no problems

    Im sorry for the cross post , but im also going to post this in the TSQL forum

  • duplicate post.(actually triplicate!)

    no need to cross post to multiple forums it fractures the answers you get and makes posters duplicate others work.

    the "Recent Posts" link shows us everything.

    continue the thread here:

    http://www.sqlservercentral.com/Forums/Topic690671-338-1.aspx

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply