Thursday, May 11, 2017

Naming Temp Tables in Stored Procedures called by Others

Beware the temp table names you use when naming such tables in a stored procedure that in turn gets executed inside other stored procedures. If both the executing and executed procedures have temp tables with the same name, you might be in for a nightmarish episode of tearing your hair roots out. If using the same #TableName in both procedures, they must have the same exact column structure. You later add a column to the executor and don't do the same to the executed, you will end up tempted to execute yourself before you figure out why you keep getting insert errors in the child proc. Bottom line, keep temp table names different in procs called by other procs.

No comments:

Post a Comment