Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Export View and SP Create Scripts in Dependency Order Expand / Collapse
Author
Message
Posted Tuesday, September 22, 2009 3:50 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, September 22, 2009 3:39 PM
Points: 6, Visits: 12
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.
Post #792240
Posted Wednesday, September 23, 2009 7:20 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 8:41 AM
Points: 870, Visits: 894
Generating scripts in SSMS will automatically be generated in the corrrect order.

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


Karl
source control for SQL Server
Post #792610
Posted Wednesday, September 23, 2009 8:36 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 12:02 PM
Points: 12,890, Visits: 31,853
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #792690
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse