DATABASE NAME AS PARAMETER IN PROCEDURE

  • HI..

    I have multiple databases . In a procedure I want to send Database name as parameter . Then I want to connect that database and execute some queries . Should any one know best solution without using dynamic sql.

    Thanks In Advance .........

    Regards,

    Reji P R

  • You have to issue a USE statement or quantify the object names in the queries with the database name. Neither method supports using a parameter which is why all you'll see for this type of operation is dynamic SQL.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply