Results 1 to 4 of 4

Thread: SP for multi DB

  1. #1
    ED Guest

    SP for multi DB

    Is it possible to create a stored procedure that can be used on multiple dBs??

    For instance, I want to create a stored procedure and use it on DB1 and DB2.
    Right now, I can create a stored procedure in DB1 but only I can run it.
    I want to run the stored procedures on DB2 that I created in DB1..

    I hope this makes sense..
    Any insight into the workings of SPs would be most appreciated...


  2. #2
    Chakri Guest

    SP for multi DB (reply)

    Create a stored procedure with sp prefix and store it in Master DB. if you try to execute any SP that starts with sp_, the system will first check for this in master DB. so you can run this SP from and DB.

    Chakri


    ------------
    ED at 3/22/01 3:45:45 PM

    Is it possible to create a stored procedure that can be used on multiple dBs??

    For instance, I want to create a stored procedure and use it on DB1 and DB2.
    Right now, I can create a stored procedure in DB1 but only I can run it.
    I want to run the stored procedures on DB2 that I created in DB1..

    I hope this makes sense..
    Any insight into the workings of SPs would be most appreciated...


  3. #3
    Guest

    SP for multi DB (reply)

    when u call this sp in db2 qualify it as db1..sp.


    ------------
    ED at 3/22/01 3:45:45 PM

    Is it possible to create a stored procedure that can be used on multiple dBs??

    For instance, I want to create a stored procedure and use it on DB1 and DB2.
    Right now, I can create a stored procedure in DB1 but only I can run it.
    I want to run the stored procedures on DB2 that I created in DB1..

    I hope this makes sense..
    Any insight into the workings of SPs would be most appreciated...


  4. #4
    Boris Guest

    SP for multi DB (reply)



    You can create store procedure in DB1 and use "USE" statements to run it see below
    Firstival you have to create sp_test stope procedure

    use northwind
    select * from Invoices
    use pubs

    exec sp_test
    drop proc sp_test

    use northwind
    select * from [Order Subtotals]

    I check it work.
    I Hope that help
    Sincerely
    Fain Boris

    ------------
    ED at 3/22/01 3:45:45 PM

    Is it possible to create a stored procedure that can be used on multiple dBs??

    For instance, I want to create a stored procedure and use it on DB1 and DB2.
    Right now, I can create a stored procedure in DB1 but only I can run it.
    I want to run the stored procedures on DB2 that I created in DB1..

    I hope this makes sense..
    Any insight into the workings of SPs would be most appreciated...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •