Dynamic T-SQL stored procedure to insert in differents tables

后端 未结 3 681
终归单人心
终归单人心 2021-01-27 16:20

What is the best way to achieve this

INSERT INTO @TableName (@ColumnNames)
    EXEC sp_executesql @SQLResult;

Where @TableName,

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-27 16:57

    The best way is to write (or generate) all reqiured procedures for all table. 23 tables times 4 procedures (insert, update, delete and select) that can be generated automatically is nothing in dev time and pain compared to the so called "generic solution".

    It's a path to poor perfomance, unreadable code, sql injection hazard and countless debuging hours.

提交回复
热议问题