Click here to Skip to main content
15,880,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have two queries like this

select *from sample1
select *from sample2

I would like to get the result in a single dataTable.
When I run this query I get the result in two grids. I want this to be in a single grid.
Posted

Hi,

Cant this be done by joining the tables or like,

select * from sample1,sample2 


Wouldnt this be the easy way instead of 2 queries and join data tables?
 
Share this answer
 
v2
Dear Friend,

If the no of columns in both the tables from the database are same then go for
DataTable.Merge()
functionality to get the result into one datatable.

Please follow link for more clarity:- http://msdn.microsoft.com/en-us/library/system.data.datatable.merge.aspx[^]

I hope this will help you out.

Thanks
 
Share this answer
 
You can use UNION or UNION ALL command in SQL.

For detailed information check the following link

http://blog.sqlauthority.com/2009/03/11/sql-server-difference-between-union-vs-union-all-optimal-performance-comparison/[^]

I hope this will help you. If this solution works for you then accept this answer otherwise revert back to me
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900