July 30, 2009 at 8:07 am
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.
July 30, 2009 at 8:25 am
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.
July 30, 2009 at 8:33 am
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 ?
July 30, 2009 at 9:20 am
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
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply