declare @tb nvarchar(50),@sql nvarchar(2000)
select @tb=name from sysobjects where type='U' and name like 'Y%'
set @sql='select * from '+@tb+' where barcode=''1234'' '
exec(@sql)
declare @sql varchar(max)
set @sql = ''
select @sql = @sql+ ' select * from '+ t.name +'where barcode=''1234'' '
from sysobjects as t join sys.all_columns as c on t.id = c.object_id and t.type='U' and c.name ='barcode' and t.name like 'Y%'
exec (@sql)