Copy SP using T-SQL

  • Is there a way to copy a stored procedure from one server to another using T-SQL? I tried writing to the sysobjects table but I get a permission denied error.

  • not really. you need to "compile" the object, you cannot copy it. You could write some T-SQL to get the data from syscomments and then exec() this to compile it. Be messy.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • I presume you are wanting to do this programmatically, since the manual method of scripting the object is straight forward.

    Have you considered creating a DTS package to transfer the SQL object(s).

    You should then be able to call the DTS package using xp_cmdexec and DTSRun.exe

  • Didn't think to use the DTS package, although I was hoping find some simple method (programatically). Thanks for your input.

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

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