sp_MSForEachTable

sp_MSForEachTable is a cool SP. It returns all the name of all Tables with the usage of a question mark "?". Is there anything else beside the usage with a question mark?

I did find this: https://www.sqlshack.com/an-introduction-to-sp_msforeachtable-run-commands-iteratively-through-all-tables-in-a-database/

Is there another one for columns?

Is there another one for other stuffs that I am not aware of?

Thanks

Once you get the database with ? then the rest is easy.
Look at sys.tables, sys.columns

1 Like

Select t.name, c.name from sys.tables t join sys.columns c
On t.object_id = c.object_id

Select * from sys.objects
Select * from sys.index

Etc