Multiple Select Statement in stored procedure
-
Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)
-
Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)
Try googling for "ado.net multiple result sets".
-
Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)
If you are trying to get multiple records from the same table them multiple selects are not required. If you have multiple records sets coming from different table then you will need multiple selects. WARNING multiple recordset returned from the same can destroy your system, it can be dramatically slower to get multiple recordsets.
Never underestimate the power of human stupidity RAH
-
Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)
Hi, coming to ur question
deepseeindeepsy wrote:
Is it possible to fetch it?
Ans : Yes I am giving a small example Step 1: Create the Stored Proc
Alter Procedure GetMultipleRecords
As
Begin
-- First select Select \* from test1 -- Second select Select \* from test2
End
So this will give u two record sets Step 2: Use Data Adapter & DataSet
From Asp.net application, by using DataAdapter get the records set into the DataSet
Step 3: Use respective datatable(s) from DataSet Get the record sets from the DataSet into DataTable(some pseudo code in c#) e.g.
DataSet ds = getDataRecords();->You will get the records from database if(ds!=null && ds.tables.count > 0) {
//Store the result for Select * from test1 into datatable firstDt
DataTable firstDt = ds.tables\[0\];
//Store the result for Select * from test2 into datatable secondDt
DataTable secondDt = ds.tables\[1\]; }
Hope you get the idea. Now try by urself and I am sure you will reach the point. Have a nice day. :)
Niladri Biswas