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 @sql varchar(max) Declare @dbName varchar(50)='Learn' SET @sql=' use '+@dbname+' go select TABLE_NAME from INFORMATION_SCHEMA.TABLES' exec (@sql)