sql - fetch data from multi tables with out relation ship between these tables -
for every week have excel sheet converted sql database excel sheet gave me 30 deference table same structure , field definition there no relationship between these tables.
so want merge data these 30 table in 1 table i'm trying write t-sql fail using information_schema.tables
or sys.tables
table names , proceed fetch data these tables in 1 query.
to combine tables exact same schema:
select * table1 union select * table2
if entire db made of these tables should able use sp_msforeachtable
procedure.
create table #temptable (col1 int, col2 nvarchar(50)) sp_msforeachtable 'insert #temptable (col1 , col2) select col1 , col2 ?' select * #temptable drop table #temptable
Comments
Post a Comment