Insert Generator - Stored Procedure

  • Comments posted to this topic are about the item Insert Generator - Stored Procedure

  • Very nice stored proc. However would like you to explain it in at various places

    such as

    what is the use of sys.index_columns

    I mean thorough explanation would also be very helpful.

    Thanks

    Lokesh

    email - er.lokeshsharma08@gmail.com

    Lokesh Sharma
    sql4all.org

  • The sys.index_columns view is utilized because it gives me the ability to join to the key_constraints view to see if the identity column is a primary key or not. This important due to the procedure parameters I accept.

    This procedure builds out a query, that when executed (which the procedure does), the results will generate the INSERT script. Based on the parameters entered it will either include the existing IDENTITY values or it will leave them out of the INSERT script. If excluded, new IDENTITY values will be generated in the destination table upon execution.

    The cursor in the procedure loops through each field in a table analyzing the field data type to determine how the select statement needs to be built out. Based on the parameters it could be built out with NOT EXISTS statements so duplicate data is not entered or it will script out just the INSERT statement.

  • It is not working for tables having UNIQUEIDENTIFIER data type. (GUID)

Viewing 4 posts - 1 through 3 (of 3 total)

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