Combine Two DataTables Into One Datatable

Hi I have Two Data Tables derived from two different sql queries.

I need to combine them into one dataTable so that new datatable can be assigned as datasource to the datagrid.

Is it possible?

Thanks
Siva.
spgaddipatiAsked:
Who is Participating?
 
pauljk1619Connect With a Mentor Commented:
you can do an inner join between the SQL statements....

this is a SQL Server syntax example.

Select * from (Select * from TugOrder where TugOrderID < 500) as A Inner Join (Select * from TugsInOrder) As B on A.TugOrderID=B.TugOrderID
0
 
PoeticAudioCommented:
or if they are matching columns from different tables you can use a union

SELECT
     A,
     B,
     C
FROM Table1
WHERE Condition = value
UNION
SELECT
    D,
    E,
    F
FROM Table2
WHERE Condtion = value

but the type of A must match D, B's type must match E and C's must match F (by type I mean DateTime, varchar...etc

This works if you're selecting similar data from 2 different tables and you want to merge it all together. For example if you have Name, Address, Phone in Customers that you want to merge with Name, Address, Phone in an Employee table (or something, not the best example, but hey)
0
 
devsolnsCommented:
Doing so in SQL would be preferred.  If not you can do it in code with the DataSet Merge() method.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.