Merge the data obtained from the two tables to form a dataset. 1. When two tables with different structures in the same database// Create table # TEM (FID int, username varchar (50), address varchar (50), fax varchar (50 )) go // insert data from Table T1 to the temporary table # TEM insert into # TEM (FID, username, address) select * from T1 insert into # TEM select * from T3 // insert T3 data to the temporary table # TEM
Select * from # TEM // get all data from the temporary table drop table # TEM // Delete the temporary table
2. Retrieve data sets from two tables with different structures under the same database and merge them into the same data set.Select * into # tempdt from T1 insert into # tempdt ([name], address) Select T3. [name], t3.address from T3 select * from # tempdt drop table # tempdt
3. Fetch data from two associated tables from different databasesSelect * from [DBO]. [database name]. [Table name] inner join [DOB]. [database name]. [Table name] On t1.id = t2.id Note: You must specify the DBO and database name here.