use
websitedb
declare @tablename varchar ( 50 )
declare @sqlstr varchar ( 300 )
declare table_cursor cursor for
select o.name
from syscolumnsc inner join sysobjectso on o.id = c.id
where o.xtype = ' u ' and c.name = ' userid '
order by o.name
open table_cursor
fetch next from table_cursor into @tablename
while ( @@fetch_status = 0 )
begin
set @sqlstr = ' select ''' + @tablename + ''' astablename,*from ' + @tablename + ' whereuserid= '' qifei '''
exec ( @sqlstr )
fetch next from table_cursor into @tablename
end
close table_cursor
deallocate table_cursor
declare @tablename varchar ( 50 )
declare @sqlstr varchar ( 300 )
declare table_cursor cursor for
select o.name
from syscolumnsc inner join sysobjectso on o.id = c.id
where o.xtype = ' u ' and c.name = ' userid '
order by o.name
open table_cursor
fetch next from table_cursor into @tablename
while ( @@fetch_status = 0 )
begin
set @sqlstr = ' select ''' + @tablename + ''' astablename,*from ' + @tablename + ' whereuserid= '' qifei '''
exec ( @sqlstr )
fetch next from table_cursor into @tablename
end
close table_cursor
deallocate table_cursor