In order to make some changes on all user tables in the DB, the system stored procedure: sp_MsForEachTable can help us alot.
Instead of using cursors and dynamic SQL, we can use this SP to execute an operation on all user tables.
The syntex and the parameters are:
Exec sp_MSforeachtable
@command1, --first command to perform
@replacechar, --Command character to be replaced with table name at run-time. default is "?"
@command2, --second command to perform (Optional)
@command3, --Third command to perform (Optional)
@whereand, --Filter for objects we do not want to include at run-time
@precommand, --Optional command you to run once before running the loop on all tables
@postcommand--Optional command you to run once after running the loop on all tables