stored proc

arkiboys 9,646 Reputation points
2024-03-18T16:32:41.9133333+00:00

Hello,

I have a stored procedure which does the following:

1- filter tables and place data into #table1

2- filter tables and place data into #table2

...

Then at the end of the stored proc, select columns by joining these #tables.

I have several stored procedures which they all have the same steps above, i.e.

1

2

...

and the only difference between the stored procs is where the tables are joined

Question:

Instead of me doing copy/paste of the #tables in steps 1, 2, ...

how can I make this generic so that each stored procedure has mostly the join tables instead of all the creation of #tables, etc.?

Thank you

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,560 questions
0 comments No comments
{count} votes