I have several databases, all with the same structure and all on the same SQL Server. And I have a stored procedure that can be used with any one of the databases. The database to be used is specified in a web page. The stored procedure creates a temporary table, builds the temporary table in a WHILE loop, in the loop a table is queried with conditions that depend on the loop counter, and finally it SELECTS the rows from the temporary table.
How can I use this procedure? Should it be a stored procedure? I want the procedure to be in one place and to run it with a variable for the database name.
How can I use this procedure? Should it be a stored procedure? I want the procedure to be in one place and to run it with a variable for the database name.