Stored Proc and Master DB

  • Hello, I have a stored procedure in a particular DB and the SP takes a 'Rolename' from the DB as Input parameter. I want to have the SP in Master DB and still be able to run across different DBs by passing the corresponding DB Roles as parameters. Is there a way to do this? Please help.

    Thanks in Advance

  • I don't know how are you using the parameter

    but this sholud helpyou going

     
    
    Declare @str varchar(200)
    SET @str = DB_NAME()--Assuming is going to be runned from other databases only
    --otherwise use dbname as a parameter

    +'.dbo.sp_helprolemember '
    + ''''
    + 'RoleName'
    + ''''
    --print @str
    exec (@str)

    I don't know why can't the "plus" sign show


    * Noel

  • Thanks very much mate. The 'DB_Name()' is going to be helpful for me on this. I shall have a go at it.

    Thanks

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

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