Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this simple query i want to retrive all the data that select is selecting plus i want to get total rows number using the same query how can i do this
SQL
SELECT
--COUNT(tblTaxingSchemeDetails.TaxSchemeDetailsId) as h,
tblTaxingSchemeDetails.TaxSchemeDetailsId,
tblTaxingScheme.TaxSchemeId, 
tblTaxingScheme.TaxSchemeName, 
tblTaxingSchemeDetails.TaxType,
TaxName,
tblTaxingSchemeDetails.TaxRate
From tblTaxingScheme INNER JOIN tblTaxingSchemeDetails  
On tblTaxingScheme.TaxSchemeId = tblTaxingSchemeDetails.TaxSchemeId
INNER JOIN tblTaxType 
on tblTaxingSchemeDetails.TaxType = tblTaxType.TaxTypeID
where tblTaxingScheme.TaxSchemeId =5@TaxSchemeId

and how can i access total row number is C#
Posted
Comments
King Fisher 22-May-14 8:30am    
Do you want To Count the Rows or to add Row numbers?
Muhamad Faizan Khan 22-May-14 8:59am    
count row

1 solution

There are two ways :
Either you have to write another query in your stored-procedure (if you are using)which will return you total record column and then you can use Dataset to display records from two tables.
or
try this if you want to do it into one query
SQL
SELECT
TotalRecords = COUNT(*) OVER(), -- this will give you total records in your qurey
tblTaxingSchemeDetails.TaxSchemeDetailsId,
tblTaxingScheme.TaxSchemeId,
tblTaxingScheme.TaxSchemeName,
tblTaxingSchemeDetails.TaxType,
TaxName,
tblTaxingSchemeDetails.TaxRate
From tblTaxingScheme INNER JOIN tblTaxingSchemeDetails
On tblTaxingScheme.TaxSchemeId = tblTaxingSchemeDetails.TaxSchemeId
INNER JOIN tblTaxType
on tblTaxingSchemeDetails.TaxType = tblTaxType.TaxTypeID
where tblTaxingScheme.TaxSchemeId =@TaxSchemeId


Thanks
 
Share this answer
 
Comments
King Fisher 22-May-14 9:18am    
Good one my 5
Schatak 23-May-14 9:31am    
:) thanks

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