I have table with information about another tables. Like this:
AccTableHistory
:
| TableName| ColumnName |
| -------- | ----------- |
| Table1 | FirstName |
| Table1 | LastName |
| Table1 | Adress |
| Table2 | FirstName |
| Table2 | SSN |
| Table2 | FamilyStatus|
etc.
I need to write an update statement for each column from this list. Should be something like:
UPDATE Table1
SET
FirstName = 'Andrew'
,LastName = 'Test'
,Adress = 'Test'
But we have more than 100 tables and more than 800 columns in the list. I don't want to write an update for each table manually.
Is it possible to write a dynamic query or stored procedure to update each table from this list (AccTableHistory table)?
I have no idea how to achieve that
1条答案
按热度按时间mlnl4t2r1#
I did it like this: