dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Get-DbaDependency's documentation should say how it finds dependencies

Open ReeceGoding opened this issue 1 year ago • 6 comments

Summarize Functionality

Neither reading Get-DbaDependency's documentation nor skimming its source code has made how it finds dependencies obvious. There are many methods for finding dependencies in SQL and none of them are perfect. If users knew what method was used and what it misses, then they would be more confident in using Get-DbaDependency.

Is there a command that is similiar or close to what you are looking for?

No

Technical Details

No technical details needed. This is only a documentation change.

ReeceGoding avatar Feb 25 '24 15:02 ReeceGoding

Just a simple addition to hopefully make the closing of this issue easier. Tracking down the logic from the Get-DbaDependency through the used there SMO classes/objects I believe that the method used is the buildin views method and I believe so due to the use of sys.sql_expression_dependencies through-out the SMO repo.

userwiths avatar Feb 26 '24 14:02 userwiths

@ReeceGoding / @userwiths : dbatools uses SMO, and that command uses dependency tracking via SMO just like SSMS does. This means that if SMO is able to trace dependencies dbatools will, too. Excluding bugs, that means basically that everything is within scope EXCEPT dynamic sql, where it's quite impossible to track down dependencies .... would a "This command uses SMO to track dependencies, so everything except dynamic sql" note on the help suffice ?

niphlod avatar Feb 26 '24 14:02 niphlod

Works for me, might want to wait and hear back from OP tho.

userwiths avatar Feb 28 '24 11:02 userwiths

@niphlod That works for me. Ideally, a hyperlink to the relevant SMO's docs would also be included.

ReeceGoding avatar Feb 28 '24 20:02 ReeceGoding

@ReeceGoding , something like https://learn.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.management.smo.dependencywalker.discoverdependencies?view=sql-smo-160 or https://github.com/microsoft/sqlmanagementobjects/blob/main/src/Microsoft/SqlServer/Management/Smo/DependencyWalker.cs is okay ? dunno how much "clear" it'd be , even linking it.

niphlod avatar Feb 29 '24 00:02 niphlod

@niphlod Yeah, that's all that I had in mind. I was hoping that there would be a smoking gun showing a DMV clearly being used, but what you have found is the best we'll get.

ReeceGoding avatar Feb 29 '24 18:02 ReeceGoding