SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Dependency problem


SQL Dependency problem

Author
Message
Dean Jones-454305
Dean Jones-454305
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1686 Visits: 1130
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.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)SSC Guru (247K reputation)

Group: Administrators
Points: 247863 Visits: 19802
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
My Blog: www.voiceofthedba.com
Dean Jones-454305
Dean Jones-454305
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1686 Visits: 1130
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 ?
Lowell
Lowell
SSC Guru
SSC Guru (137K reputation)SSC Guru (137K reputation)SSC Guru (137K reputation)SSC Guru (137K reputation)SSC Guru (137K reputation)SSC Guru (137K reputation)SSC Guru (137K reputation)SSC Guru (137K reputation)

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