change owner on SP

  • how do you change the owner name on a stored procedure to another owner name?

    Thanks ahead of time!

  • From BOL:

     

    EXEC sp_changeobjectowner [ @objname = ] 'object' , [ @newowner = ] 'owner'



    Shamless self promotion - read my blog http://sirsql.net

  • Line 1: Incorrect syntax near 'insert_test_1'.

     

    insert_test_1 is the stored procedure name

    I used {EXEC sp_changeobjectowner [ @objname = ] 'insert_test_1' , [ @newowner = ] 'jttested'}

    What am I doing wrong?

    Thanks!

     

  • You appear to have left in the marks used within BOL to indicate how to write commands. Try:

    EXEC sp_changeobjectowner 'insert_test_1', 'jttested'

       Philip

     

  • Server: Msg 15001, Level 16, State 1, Procedure sp_changeobjectowner, Line 38

    Object 'insert_test_1' does not exist or is not a valid object for this operation.

    yep tryed that before also and got this error when doing it this way. Not sure why when then stored procedure is insert_test_1.

    Thanks!

  • What is your original owner, dbo or someone else?

    sp_changeobjectowner 'oldowner.sp', 'newowner'

  • Doh! That's it exactly, you have to use two-part naming to specify the old owner of the object as well as the object--and, as Allen shows, enter just the new owner in the second parameter.

       Philip

     

  • Also make sure the current database is the one that contains the stored procedure you're working with.

    Greg

  • That was it you guys are great Thanks!

Viewing 9 posts - 1 through 8 (of 8 total)

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