• Jan Van der Eecken (6/18/2013)


    There's nothing wrong in the CreateProcessTable script, in fact you wouldn't be able to do this in any different way anyhow. Building the column list in the LoadProcessFromTarget script will also constitute a neglible part of the time the entire load takes you, and in fact the LoadTargetFromFile script can't be improved much either, except maybe for the fact that you could TRUNCATE the @TargetTable instead of DELETEing from it (assuming there are no foreign keys referring to it of course).

    But yes, you could build the column list in the two latter scripts in a few less milliseconds by not using a cursor, I guess that won't make a difference, unless you have a few million tables to create. It certainly won't make a difference unless the majority of tables to load are empty, otherwise the load of data times will outdwarf the time it takes to build the tables.

    I think if I asked how to do this with a cursor and a loop, I would have gotten a hundred ways to do it without a cursor and a loop 😉

    I do appreciate the feedback, but my question wasn't performance related, really. I'm curious what people use instead of cursors and loops. The code I posted was an example of where I use them, so determining the appropriate replacement method wouldn't be a total shot in the dark.

    Thanks