Export View and SP Create Scripts in Dependency Order

  • Hi,

    I know that someone has probably done this but I'm having no lucking finding anything.

    We are creating a new company division. This requires that all the objects in our standard division database be replicated in a new database. The trick is that most SPs, Views and Triggers have some dependencies on each other. So, I need to export the Create scripts for these objects in the correct order so that that I can just paste and go in the new database.

    Does anyone have a script that does that?

    thanks.

  • Generating scripts in SSMS will automatically be generated in the corrrect order.

    Just right-click on the Database > Tasks > Generate Scripts.

  • i don't remember the scripts coming out in order, I'm testing it now...the wierd thing is, on a decent size database, with 2000+ objects, it's still running the Script wizard for over an hour....on TWO different servers, since i thought maybe it was just me.

    I did notice it is going thru the objects in object type, then alphabetical order, but it might be arranging the data in dependancy order...not sure yet.

    the easiest way to get all your objects in order is to run this command:

    EXEC sp_msdependencies @intrans = 1

    I've used this to manually script all my objects via TSQL...tables, functions/procs/views.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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