Named Recordsets from SProcs?

A

A Traveler

Hello,

I have a SQL Server stored procedure which will return several recordsets
back to the caller (multiple SELECT statements).
By default when you call this stored proc from ADO.NET, you get back the
tables in the DataSet as Table, Table1, Table2, etc....
Is there anyway in the sproc that i can name them so that when they come
back to ADO, the DataSet contains them with friendly names, like TBL_HEADER,
TBL_DETAILS, TBL_LOCATIONS, etc.... ??

Thanks in advance,

- Hitchhiker.
 
W

William \(Bill\) Vaughn

Nope, but you can change the TableMappings collection to map Table, Table1
etc. to their correct names. The rowsets being returned from the SP don't
have names so ADO has no way of knowing what to call them. Not all rowsets
are simply SELECT * FROM myTable queries.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
A

A Traveler

Yah, i know they could get more complex, i just thought maybe there was some
way to do something like

SELECT * FROM (SELECT whatever whatever) AS MYTableName

Oh well... thanks anyway for ALL your help on my questions thus far.
 
W

William \(Bill\) Vaughn

No problem. Just consider that it's bad form to do a SELECT * and especially
without a WHERE clause. IMHO the "DataTable" should have been called the
"DataRowset" object. This way developers would know it's designed for
rowsets, not entire tables. Sure, there are cases when the database is
simple that fetching the whole table makes sense. It doesn't in production
systems that you expect to scale.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
A

A Traveler

Yeah. i dont generally do unfiltered SELECT *'s except on things like lookup
tables where its just a small set of ID/TEXT combinations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top