0

我在查找 SSIS 包的物理路径时遇到问题,因为我移交了某人的工作,并且 SSIS 中的包名称与光盘中的不同。有很多 SSIS,很难找到正确的。我找到了显示所有包的解决方案,但没有关于物理路径的信息。请停下来。

with ChildFolders
as
(
    select PARENT.parentfolderid, PARENT.folderid, PARENT.foldername,
        cast('' as sysname) as RootFolder,
        cast(PARENT.foldername as varchar(max)) as FullPath,
        0 as Lvl
    from msdb.dbo.sysssispackagefolders PARENT
    where PARENT.parentfolderid is null
    UNION ALL
    select CHILD.parentfolderid, CHILD.folderid, CHILD.foldername,
        case ChildFolders.Lvl
            when 0 then CHILD.foldername
            else ChildFolders.RootFolder
        end as RootFolder,
        cast(ChildFolders.FullPath + '/' + CHILD.foldername as varchar(max))
            as FullPath,
        ChildFolders.Lvl + 1 as Lvl
    from msdb.dbo.sysssispackagefolders CHILD
        inner join ChildFolders on ChildFolders.folderid = CHILD.parentfolderid
)
select F.RootFolder, F.FullPath, P.name as PackageName,
    P.description as PackageDescription, P.packageformat, P.packagetype,
    P.vermajor, P.verminor, P.verbuild, P.vercomments,
    cast(cast(P.packagedata as varbinary(max)) as xml) as PackageData
from ChildFolders F
    inner join msdb.dbo.sysssispackages P on P.folderid = F.folderid
order by F.FullPath asc, P.name asc;
4

3 回答 3

1

我的SSIS 包查询与您的类似。您的路径和我的路径之间的区别在于,我使用反斜杠进行路径,而您使用正斜杠。

;
WITH FOLDERS AS
(
    -- Capture root node
    SELECT
        cast(PF.foldername AS varchar(max)) AS FolderPath
    ,   PF.folderid
    ,   PF.parentfolderid
    ,   PF.foldername
    FROM
        msdb.dbo.sysssispackagefolders PF
    WHERE
        PF.parentfolderid IS NULL

    -- build recursive hierarchy
    UNION ALL
    SELECT
        cast(F.FolderPath + '\' + PF.foldername AS varchar(max)) AS FolderPath
    ,   PF.folderid
    ,   PF.parentfolderid
    ,   PF.foldername
    FROM
        msdb.dbo.sysssispackagefolders PF
        INNER JOIN
            FOLDERS F
            ON F.folderid = PF.parentfolderid
)
,   PACKAGES AS
(
    -- pull information about stored SSIS packages
    SELECT
        P.name AS PackageName
    ,   P.id AS PackageId
    ,   P.description as PackageDescription
    ,   P.folderid
    ,   P.packageFormat
    ,   P.packageType
    ,   P.vermajor
    ,   P.verminor
    ,   P.verbuild
    ,   suser_sname(P.ownersid) AS ownername
    FROM
        msdb.dbo.sysssispackages P
)
SELECT 
    F.FolderPath
,   P.PackageName
,   F.FolderPath + '\' + P.PackageName AS PackagePath
,   P.packageFormat
,   P.packageType
,   P.vermajor
,   P.verminor
,   P.verbuild
,   P.ownername
,   P.PackageId
FROM 
    FOLDERS F
    INNER JOIN
        PACKAGES P
        ON P.folderid = F.folderid;

结果(对于默认的 2008 框)。

FolderPath  PackageName PackagePath
\Data Collector PerfCountersCollect \Data Collector\PerfCountersCollect
\Data Collector PerfCountersUpload  \Data Collector\PerfCountersUpload
\Data Collector QueryActivityCollect    \Data Collector\QueryActivityCollect
\Data Collector QueryActivityUpload \Data Collector\QueryActivityUpload
\Data Collector SqlTraceCollect \Data Collector\SqlTraceCollect
\Data Collector SqlTraceUpload  \Data Collector\SqlTraceUpload
\Data Collector TSQLQueryCollect    \Data Collector\TSQLQueryCollect
\Data Collector TSQLQueryUpload \Data Collector\TSQLQueryUpload
于 2013-07-22T18:15:12.457 回答
0

我找到了解决方法。我刚刚在 Visual Studio 中创建了新的 SSIS 项目,并且可以选择添加现有的 SSIS 包:

在此处输入图像描述

然后我刚刚登录到存储包的服务器:

在此处输入图像描述

并导航到我正在寻找的包裹。

于 2015-02-12T13:52:10.127 回答
0

使用folders_cte下面的公用表表达式。然后加入folders_ctemsdb.dbo.sysssispackages表上的folderid列。从那里开始,在最底部的 SELECT 子句中添加额外的列相对容易,但为简单起见,我只包括了三个。

;WITH folders_cte AS 
(
    SELECT 
        p.folderid,
        p.parentfolderid,
        p.foldername,
        CAST(p.foldername AS VARCHAR(8000)) [path]
    FROM msdb.dbo.sysssispackagefolders p
    WHERE folderid = '00000000-0000-0000-0000-000000000000' 
    UNION ALL 
    SELECT 
        c.folderid,
        c.parentfolderid,
        c.foldername,
        CAST(folders_cte.path+c.[foldername] + '\' AS VARCHAR(8000)) [path]
    FROM msdb.dbo.sysssispackagefolders c
    INNER JOIN folders_cte on
    c.parentfolderid = folders_cte.folderid
)
SELECT f.path Path, p.name PackageName, f.path + p.name AS FullPath
FROM msdb.dbo.sysssispackages p
INNER JOIN folders_cte f ON 
p.folderid = f.folderid
于 2016-09-09T20:15:26.833 回答