'Migrate similar stored procedures from various databases to single database

I have 2 databases DB1, DB2 which have same table structure tbl_Detail. And both the databases have same stored procedure sp_GetDetails which has same scripts as below:

Create procedure sp_GetDetails
AS
Begin
    select * from tbl_Detail
End

I need to move this from both these databases and place in a single database DB3.

I tried using linked server and passed an input param as dbname to the stored procedure.

But it requires to convert the script into dynamic SQL.

Is there any other way to achieve this, as I do not want to use dynamic SQL, since there are hundreds such stored procedures and the number of statements in each stored procedure are more.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source