Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A single sql query to return as multiple tables in a dataset

Tags:

c#

sql

I was wondering if i can use a single query in sql server 2005 to return as a dataset in c#, asp.net 2005 into different tables.

DataSet ds = new DataSet();
ds = new BusinessLogic.BizLogic().getData(int repID);
for(ds != null)
{
    txtDate.Text = ds.Tables[2].Rows[0]["Date"].ToString();
}

Want to figure out, how to write the store procedure to have multiple tables.A simple example would be appreciated. Thank you!

like image 422
challengeAccepted Avatar asked Dec 22 '22 00:12

challengeAccepted


1 Answers

You absolutely can, although you may want to consider the overall goal and implications of considering this design.

In your stored procedure you just simply have multiple selects ala..

select xxx, yyy from table1
select zzz, nnn from table2

Along those lines.

like image 140
Quintin Robinson Avatar answered Dec 23 '22 12:12

Quintin Robinson