EG1:
Let me know that if you change a table owner to DBO, just need
Sp_changeObjectowner 'table name,' DBO '
But you want to change all the owners of all tables to DBO, you can use loop processing, this is a slight
In fact, SQL system stored procedure sp_msforeachtable can be easily set
Just exec SP_MSFOREACHTABLE 'SP_CHANGEOBJECTOWNER' '?' ',' 'Dbo' ''
Of course, it may be wrong when it runs (for example, the owner of some table is DBO), it doesn't want it, it will run again.
EG2:
All tables plus a self-growth field
Everyone knows if it is added to a form: ALTER TABLE Name Add Iid Int IDENTITY (1, 1)
If you need to add it to all the tables, you only need: sp_msforeachtable 'alter table? Add iid int identity (1, 1)'
Similarly, delete the IID field in all tables Just sp_msforeachtable 'ALTER TABLE? DROP Column IID'
Of course, it may be wrong when it runs (such as adding fields, there is no such field when deleting fields), and does not need it, run it over again.
EG3:
Four reservoir processing for NUM fields in all tables
SP_MSFOREACHTABLE 'UPDATE? SET NUM = Round (NUM, 2)'
Of course, it may be wrong when it runs (such as there are no NUM fields in some tables), don't use it, run it over again.