Thursday, August 25, 2016

Query to All / Selected tables using undocumented SQL Procedure sp_msforeachtable

In this article, we will see basic use of undocumented procedure sp_MSforeachtable 
E.g. Adding any column to each user-defined table in SQL Server:

exec sp_msforeachtable 'alter table ? add flag bit not null default 0';