Fetching all the tables and their data in MSSQL and mySQL
Can you guys tell me how to fetch all the tables 开发者_如何学Calong with their records considering we don't know the table names in the database.
Such as :
use my_database
select * from information_schema.tables
-- gives all the tables from a database
Also it would be great if you can give mySQL and MSSQL queries.
I thought it would work but didn't work out:
select * from (select [TABLE_NAME] from INFORMATION_SCHEMA.TABLES)
For SQL Server you can use this:
exec sp_msforeachtable 'select * from ?'
精彩评论