Our DB has around 30 SProcs - I need to move them into a script, so that it can be easily added to another server. The way I'm creating the script is to highlight all the SProcs, then copy - in my notepad screen, I paste, which gives me one script, which includes all the individual creation scripts for the Sprocs.
However, I'm getting an error when I create the script -
Cannot add rows to sysdepends for the current stored procedure because it depends on the missing object 'SP_MySproc'. The stored procedure will still be created.
So - what's a good, and/or easy way to structure the script, so that I can easily find WHERE to put Which SProc Script, in the list?
Hey,
You could follow those steps:
Right click Database in Sql Server Management Studio -> Tasks->Generate Scripts->choose databse ->...->check Stored Procedure->next...
|||That still gives me the same error - I guess what I'm asking is:
how can I figure out what order the Stored Procedures need to be scripted, so this error doesn't happen?
|||Hi
The generate script option only guarantees that the script can pass compile and the order is determined by design.
If you don't mind you could execute script twice and error should go away in the second time.
Hope this helps.
|||Hi,
If you are sure that all procedures you need are in your script do not worry about the errors, procedures will be created and will work. The only problem will be if you call procedures from another table which are not scripted or if you script your procedures into another database (with different name) and you used call like exec [Sourcedatabase].[dbo].[Procedurename] so it is possible in this case that your procedures will not work if database [Sourcedatabase] is not visible on your server from inside your destination database so check your script for "long" calls.
If you would like to have procedures in correct order you can write TSQL script which will script procedures for you in correct order, I hear about application which can do it for you and you can do it by hands by ordering your procedures in the script the way that procedure is defined before is called by another procedure.
Thanks
JPazgier
No comments:
Post a Comment