I have a large number of tables (some thousands) containing similar data. I would like to run some reports from these. The table names are similar, so I can get a list of table
using your pattern on table name - i got somewhere with
DECLARE @SQL nvarchar(max); select @SQL = COALESCE(@SQL , '') + 'SELECT * FROM [' + TABLE_NAME + '] UNION ALL ' FROM INFORMATION_SCHEMA.TABLES where TABLE_NAME LIKE '%employeedet%'; SELECT @SQL = LEFT(@SQL, LEN(@SQL) - 11); print @SQL;