1
我需要使用SMO來找出註冊程序集(SQLCLR)的所有依賴關係。 我該怎麼做? 謝謝,內斯特SMO - 程序集依賴關係
我需要使用SMO來找出註冊程序集(SQLCLR)的所有依賴關係。 我該怎麼做? 謝謝,內斯特SMO - 程序集依賴關係
其實,這裏是一個更好的答案:
static public List<Urn> GetDependencies(SqlAssembly assembly)
{
return GetDependencies(assembly.Parent.Parent, assembly.Urn);
}
static public List<Urn> GetDependencies(Server server, Urn obj)
{
Scripter scr = new Scripter(server);
DependencyTree tree = scr.DiscoverDependencies(new Urn[] { obj }, DependencyType.Parents);
DependencyWalker depwalker = new DependencyWalker();
DependencyCollection depcoll = depwalker.WalkDependencies(tree);
List<Urn> dependencies = new List<Urn>();
foreach (DependencyCollectionNode dep in depcoll) dependencies.Add(dep.Urn);
return dependencies;
}
我想我可以使用T-SQL查詢它:
select
a.name as 'assembly',
(select name from sys.assemblies where assembly_id = r.referenced_assembly_id) as 'referenced_assembly'
from sys.assemblies a left outer join sys.assembly_references r on (a.assembly_id=r.assembly_id)
where a.is_user_defined = 1
order by assembly
:-)