There is an application, it maintains delete flag column i.e. if a delete happen the column marked as 1
(in the deleted
column).
To retrieve the record I must take this 1
to a NULL
There are 135 tables having the deleted column, and all of them must be updated based on ID
column (when it has particular value)
( SELECT *
FROM INFORMATION_SCHEMA.columns
WHERE COLUMN_NAME = 'deleted')
How can I perform: UPDATE all tables containing the deleted
column SET deleted = NULL WHERE ID = 'XXXX'
Best Answer
If this is a manual update you could script out the commands you need:
But, be wary of these
INFORMATION_SCHEMA
dmvs.Aaron Bertrand lists some good reasons not to use them in this blogpost on bad habits:
So here is another solution using
sys.tables
&sys.columns
Testing
Result for both:
DB<>Fiddle