Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have a stored procedure with 'n' no. of select queries in it. When I assign this to a dataset I want to name the datatables as it is with the name of the tables for which I have written the select queries.

For Ex: The below stored proc will return a dataset with 3 datatables and I should assign the name for Table1 as t1 and for table2 as test and table3 as test1.

Is this possible without hard coding?

SQL
CREATE PROCEDURE [dbo].[MY_StoredProc]
AS
BEGIN

    select * from t1
    select * from test
    Select * from test1

END



Thanks & Regards,
Mathi.
Posted
Comments
Maciej Los 12-Sep-13 2:13am    
Could you be more specific? If i understand you well, you want to get the names of tables returned by SP. Am i right?
Mathi2code 23-Sep-13 5:01am    
yes exactly

I think it could be done. You can build intelligence by returning table names as last column name. After this you simply need to alter your data loading code. After you call the stored procedure you simply read last column of the data and save it as table name.
 
Share this answer
 
Comments
Mathi2code 23-Sep-13 5:08am    
Thanks
 
Share this answer
 
Comments
Maciej Los 12-Sep-13 7:28am    
+5
Mathi2code 23-Sep-13 5:08am    
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