Writing from memory, but it goes something like this:
SELECT *
FROM sys.tables WHERE name like '%_EmailInfo'
DECLARE @email_tables table (id int IDENTITY (1,1), table_name varchar(255))
INSERT INTO @email_tables( table_name)
SELECT objectname FROM sys.tables WHERE name like '%_EmailInfo'
DECLARE @i int
SET @i = 0
DECLARE @sql_query nvarchar(MAX)
DECLARE @table_name varchar(255)
DECLARE @exists int
WHILE (SELECT TOP 1 FROM @email_tables WHERE id > @i ORDER BY id)
BEGIN
SELECT TOP 1 @i = id, @table_name = table_name FROM @email_tables ORDER BY id)
SET @sql_query = 'SELECT COUNT(*) FROM ' + @table_name + ' WHERE emailid = ''' + @CheckEmail + '''
EXEC @exists = sp_Execute @sql_query (you'll have to check exact syntax here )
END
If this helps please take time to accept the solution. Thank you.