﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Sequence of Database Objects Dependency - SQL 2005 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 14:11:13 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Sequence of Database Objects Dependency - SQL 2005</title><link>http://www.sqlservercentral.com/Forums/Topic676289-338-1.aspx</link><description>HelloThe problem with the tables, PKs and FKs might be not so difficult:* Create all tables* Create all the primary keys (this might be done within the first step.* Create all FKs. Now all tables are available and all the FKs can be createdIt becomes more tricky with the views and (especially) the functions and procedures. Maybe have a look to ths sys.sql_dependencies:[code]SELECT *, OBJECT_NAME(object_id) origin, OBJECT_NAME(referenced_major_id) destination    FROM sys.sql_dependencies[/code]With this information you can try to script the objects by dependency. But be carefull that there are no circular references!GreetsFlo</description><pubDate>Mon, 16 Mar 2009 05:43:10 GMT</pubDate><dc:creator>Florian Reischl</dc:creator></item><item><title>Sequence of Database Objects Dependency - SQL 2005</title><link>http://www.sqlservercentral.com/Forums/Topic676289-338-1.aspx</link><description>Hi All,I want to know , as to how we can find the order of dependency in SQL Server 2005 for the objects. I currently have a database and From this EXISTING DATABASE, I have created 1. Database Creation scripts2. Table creation Scripts3. Creation scripts for Views4. Creation Scripts for Functions and Stored Procedures.Now ,during deployment of my scripts onto the production server, I wanted to let you know the sequence in which the scripts get executed. I believe the order should be something like1. Create Database script2. Table Creation Scripts3. View creation scripts4. Scripts for creating functions and stored procedures.Since there are many tables , and some tables reference the other table , due to primary key - foreign key relation , I need to make sure that I create the base most table first and then the other tables in the sequential order.  Now given the fact that I already have the database now, how do I find the dependency of one object over the other and the first database object to be created. I know that there is a stored procedure sp_MSdependencies, but that gives the oSequence as 1 for all tables.  Can anyone help me figure out the sequence.Thanks in Advance</description><pubDate>Mon, 16 Mar 2009 01:09:25 GMT</pubDate><dc:creator>msforumpost</dc:creator></item></channel></rss>