Is it possible to return multiple datasets from a stored procedure?
e.g.
CREATE PROCEDURE [dbo].[usp_vvvv] (....)
.....
SELECT *
FROM #_temp_client_details
SELECT *
FROM #_temp_address_details
DROP TABLE #_temp_client_details
DROP TABLE #_temp_address_details
....
END TRY
BEGIN CATCH
..
END CATCH
END
In my scenario, I need to get datasets from 3 different temp tables into my python code.
All 3 different temp tables are constructed using same tables, same parameters with some manipulations. So, I don't want to create 3 separate stored procedures (because all 3 stored procedures are going to use 90% same SQL logic).
I currently get the output from one of the stored procedure like:
import pandas as pd
def execute():
query='exec [zzz].[dbo].[sp_zzz]?, ?, ?, ?'
df = pd.read_sql(query, cnxn, params=[astart, aend, lstart,
lend])
writer = pd.ExcelWriter('output.xlsx')
df.to_excel(writer, index=False, sheet_name='client')
writer.save()
Is it possible? If so how can I get all tables output into pandas?