I need to get all table names in SQL Server. To do this I use this code:
select TABLE_NAME from INFORMATION_SCHEMA.TABLES
I need use dynamic
DECLARE @dbName varchar(50)='Learn' EXEC ('SELECT TABLE_NAME FROM ' +@dbName+'.INFORMATION_SCHEMA.TABLES');
OR SIMPLY:
SELECT TABLE_NAME FROM Learn.INFORMATION_SCHEMA.TABLES