How do I dynamically set the table and field name in an update query?

前端 未结 3 1123
独厮守ぢ
独厮守ぢ 2021-01-24 01:37

I\'d like to loop over a list of tables. For each table, I\'d like to run an update query.

Psuedo code:

ArrayOfTablesObjects = {[\'tablename1\',\'fieldn         


        
3条回答
  •  礼貌的吻别
    2021-01-24 02:10

    This can only be done using dynamic SQL. This is a very dangerous techique to use and should never be done without a great deal of thought as to how it could harm the database and how you can write it more carefully to protect the database. Please read this article before you consider writing dynamic SQL. http://www.sommarskog.se/dynamic_sql.html

提交回复
热议问题