Home Forums SQL Server 7,2000 General query to get a specified number of fields from all the tabels in a dbase RE: query to get a specified number of fields from all the tabels in a dbase

  • chris's idea is probably the simplest. Not sure this will get you what you want (multiple result sets), but there isn't an easy way to do that. Could insert the values into a temp table and then select them all out of there at the end.

    create table #mytemp

    ( tablename, id, datumarchief)

    exec sp_msforeachtable 'insert #mytemp select ''?'' as tablename, id, datumarchief from ?

        where datumarchief is not null'

     

    select * from #mytemp

    drop table #mytemp