Fetching Total Records Count from different tables with the help of Union All Query.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 909
Suppose,i have 2 tables viz. test1 and test2 and i want to get both tables records count,then i will write below query as:-
Select Count(1) as Row_Count From(
Select Id,Name,Address from test1
Union All
Select Id,Name,Address from test2
) as result

Note:- if table Test1 has 20 rows and Test2 as 10 Rows,then above query will produce 30 as row count.

Comments or Responses

Login to post response