• Okay, I'm thinking that this is intended to be deployed as two separate scripts. To be more useful, I would suggest the following:

    * have this automatically run for each table in the database (per my suggestion above)

    * have the Insert and the Update be parsed into separate create statements, separated by a GO

    * have all of the output for the whole job go to a single file (with all of the creates preceded by a Drop Procedure and followed by a GO)

    * also add a simple SELECT *

    * have the proc names begin with spIns and spSel and spUpd

    Then you could, in a click, generate the whole deal!

    I think that on one hand this script argues for the power of TSQL to do significant stuff while on the other hand it argues that CLR is probably going to come into play in the future for complicated stuff.

    "What I lack in youth I make up for in immaturity!"
    Please visit my music site at http://woundedego.com