SSIS物理路径

时间:2013-07-22 17:07:07

标签: tsql ssis

我在查找SSIS包的物理路径时遇到问题,因为我切换了某个人的工作,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;

3 个答案:

答案 0 :(得分:1)

我的SSIS Package Query与您的相似。你和我的路径之间的区别在于我有一个反斜杠用于路径,而你使用正斜杠。

;
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

答案 1 :(得分:0)

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

enter image description here

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

enter image description here

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

答案 2 :(得分:0)

使用下面的folders_cte公用表表达式。然后将folders_cte加入msdb.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