T-SQL -- store common definitions

I am using Transact-SQL for Azure SQL Database with stored procedures and user-defined functions. I frequently find a need to cut and paste variables used as constant definitions between procedures. Is there any way to store and reference common definitions across procedures or functions?

No, not native capability to do that within SQL Server.


If you can create a "master wrapper" stored procedure that calls the other procedures, then you can have variables in the wrapper that can be passed to the other stored procedures as parameters and have them be passed back to the wrapper.

I know little of Azure but if it allows TempTables to be created, the wrapper proc could also create a TempTable that could be used by all of the stored procedures called by the wrapper proc.

1 Like