Ya i understand u require the values of the columns.The below script will do the same
Modify this script to suit your need and to meet the performance.The previous post will give the logic of this script:
create table t1 (i int ,j varchar(20))
create table t2 (k int ,l varchar(20))
create table t3 (m int ,n numeric(10,3))
insert into t1 values (1,'hello')
insert into t1 values (2,'world')
insert into t1 values (3,'excellent')
insert into t2 values (1,'hello')
insert into t2 values (2,'happy')
insert into t2 values (3,'great')
insert into t3 values (1,2.5)
insert into t3 values (2,5.5)
insert into t3 values (3,7.5)
declare @name varchar(50)
declare @col varchar(50)
declare @value varchar(50)
declare @STR varchar(1000)
declare @i int
declare @count int
select @value = 'hello'
declare @table table(id int identity(1,1), tablename varchar(50),columnname varchar(50))
insert into @table
select a.name, b.name
from syscolumns b,sysobjects a
where a.id = b.id
and a.type = 'U'
and b.xtype = 167
and a.name in ('t1','t2','t3')
select @count = count(*) from @table
select @i = 0
while (@i <=@count)
begin
select @name = tablename ,@col = columnname
from @table where id = @i
select @STR = 'select * from ' + @name + ' where ' + @col + ' = ''' + @value +''''
select @STR
exec(@str)
select @i = @i + 1
end