In SQL Server, I want to use the same query for all the tables in a database
I need to find a way to perform the same query to all the tables in an specific database.
For example, if my database DB has the tables Table1, Table2, Table3, Table4 and Table5, I want to perform the query
SELECT * FROM <All 5 Tables>
Anyone knows how to do this?
USE [DB] exec sp_msforeachtable 'SELECT * FROM ?'