• It looks like a simple message broking pattern.

    For me the first thing I would look to do is refactor the messages to XML; this will increase the size of the file but it has two advantages. Firstly then data is syntactically referenced (i.e. you can see by looking in the file what the data represents). Secondly XML will allow you to collect all of the relevant data together into a single file. For example, Assuming DataType 1 is an Order Header and type 2 is the order lines and type 3 is the payment data

    Currently you have to process the type 1 line first or the relationship between the lines and header does not exist. You then have to process each line separately; if one line fails, what do you do with the other lines and the header. If you try to process the lines before the header do you fail them or assume late arriving data.

    If the data is in XML then the whole order comes through as a single message

    <ORDER>

    <ID>12356</ID>

    <CUSTOMER>XYZ123</CUSTOMER>

    <ORDERLINES>

    <ORDERLINE>

    <LINEID>1</LINEID>

    <ITEMID>FFGG55</ITEMID>

    <QTY>3</QTY>

    <PRICE>9.99</PRICE>

    </ORDERLINE>

    <ORDERLINE>

    <LINEID>2</LINEID>

    <ITEMID>WIDGET7</ITEMID>

    <QTY>1</QTY>

    <PRICE>100.00</PRICE>

    </ORDERLINE>

    </ORDERLINES>

    <PAYMENTS>

    <PAYMENT>

    <METHOD>AMEX</METHOD>

    <AMOUNT>109.99</AMOUNT>

    <AUTHCODE>123765</AUTHCODE>

    </PAYMENT>

    </PAYMENTS>

    </ORDER>

    Now you can validate the file against a DTD and process the entire file as a single transaction with a commit or rollback if there is a fatal error

    Failing that each SP should have static code and receive the data as parameters. If the SSIS is not already deciding which SP to call then I would do that in the SSIS rather than have a master sproc that decides which child sproc or INSERT routine is going to be run. This is a rare case of where I would try to put it into SSIS even though it could be done by the database engine - you can get better visibility and logging of what conditions are being applied. If there is no dependency between the messages and therefore the order of processing is not critical, you would even get performance increases from parallel processing of records by putting the procedure calls at outout from a conditional split task.