Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL Dependency problem Expand / Collapse
Author
Message
Posted Thursday, July 30, 2009 8:07 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, November 16, 2015 5:34 AM
Points: 282, Visits: 1,130
Hi All,

I was wondering if there was a free way to arrange dependency for SQL objects, especially views and functions.

I have heard about dependency tracker, but I am just after a script or application that will tell me objects that are not properly ordered from a dependency perspective.

Also, is there an easy way to order objects (views and functions) programmatically without having to run Alter command statements?

Kind regards.


Post #762427
Posted Thursday, July 30, 2009 8:25 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 4:47 PM
Points: 33,537, Visits: 17,669
Do you mean those objects created out of order? Or are you trying to find objects that are dependent on something that hasn't been created?

This isn't easy to figure out, and it's something that the testing teams in products have spent a lot of time going over to be sure their compare type tools work. I don't know of anyone that's built a script to give you dependency orders.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #762445
Posted Thursday, July 30, 2009 8:33 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, November 16, 2015 5:34 AM
Points: 282, Visits: 1,130
I meant objects created out of order, the problem is more apparent when you deploy large sets of scripts and one procedure fails because it was created first before the one underneath it.

More like in replication, when replicating to subscribers. if the order in which objects are scripted out is screwed then replication will fail, any solutions to this problem ?
Post #762455
Posted Thursday, July 30, 2009 9:20 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 7:52 PM
Points: 14,189, Visits: 37,086
getting the objects in dependancy order is pretty easy;
here is an example:
  CREATE TABLE #MyObjectHierarchy 
(
HID int identity(1,1) not null primary key,
ObjectId int,
TYPE int,OBJECTTYPE AS CASE
WHEN TYPE = 1 THEN 'FUNCTION'
WHEN TYPE = 4 THEN 'VIEW'
WHEN TYPE = 8 THEN 'TABLE'
WHEN TYPE = 16 THEN 'PROCEDURE'
WHEN TYPE =128 THEN 'RULE'
ELSE ''
END,
ONAME varchar(255),
OOWNER varchar(255),
SEQ int
)

--our list of objects in dependency order
INSERT #MyObjectHierarchy (TYPE,ONAME,OOWNER,SEQ)
EXEC sp_msdependencies @intrans = 1

select * from #MyObjectHierarchy

i use that along with a script contribution i made to export all DDL schema into a table in TSQL; kind of handy for having a snapshot of the schema on a daily/weekly basis, makes it simple to compare and all that...

does the above help you at all?


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!
Post #762495
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse