I have Three stored Procedures A,B,C C is a common procedure which derives data into a common table depending on parameters from respective procedures A or B and returns to a or b for further processing on one sql 2019 environment its working normally but on another if Proc A is executed first then later if procedure B is executed procedure b would return error after lot of debugging finally i tried calling proc C from A or B with recompile option then its working fine need a solution other than recompile any help appreciated. Please guide if any Sql Server settings can resolve as it works on sql 2019 server but on two different environments but failing on one.
Procedure C basically is a collection of dynamic sql which returns table required with data according to the caller, like If A calls C with Parameter ColumnName Distance C will process and return a table with Say DynamicMaster with column Distance added along with respective Data,and if B calls C with Parameter cloumn Time, C will process Data and Return a common table only with Column Time Instead Of Distance which is called from A but whats happening is if A is called earlier it returns DynamicMaster Table with Column Distance ,but after that if B procedure is executed expecting DynamicMaster Table with Column Time it gives error Column Time does not exist the DynamicMaster is created in Proc C and data collated in C itself this is working fine with one environment but failing in another environment of sql 2019