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

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: Today @ 4:31 AM
Points: 282, Visits: 1,091
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 @ 8:53 PM
Points: 33,204, Visits: 15,353
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: Today @ 4:31 AM
Points: 282, Visits: 1,091
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: Friday, August 29, 2014 7:44 AM
Points: 12,910, Visits: 32,015
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

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

Add to briefcase

Permissions Expand / Collapse