Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Export View and SP Create Scripts in Dependency Order


Export View and SP Create Scripts in Dependency Order

Author
Message
dthompson-893123
dthompson-893123
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
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.
SQLZ
SQLZ
SSC Eights!
SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)

Group: General Forum Members
Points: 930 Visits: 940
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
Lowell
Lowell
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18203 Visits: 39425
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!

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search