• Not sure if I explained this very well so I will try again!

    I have a table with the following columns:

    TABLE NAME = Phonetic_Keys

    RecordID, PhoneticSurname, PhoneticForename, PhoneticStreet, PostCode, Premise

    This table will be populated from incoming data which could contain the following columns:

    TABLE NAME = New_Data

    ID, Forrename, Surname, Address1, Address2, Address3, Town, PostCode

    If my incoming file is like above then I need to build an insert statment to populate the Phonetic_Keys table.

    However, the incoming file may not have a forename or a address3 so I've used a series of IF ststements to build my SELECT statment to be used to insert into the phonetic keys table.

    Please see code above. Is this a good way to do it?

    I seem to have many IF statmements to check for columns before I build my dynamic insert statement.

    Any ideas?

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn