2009-06-30 78 views
0

我被要求這樣做,但我不知道是否有這樣做的標準方式。有誰知道是否有方法在SQL Server中導出?是否可以將我的SQL複製定義導出到XML?

+0

您能否定義您的定義是什麼意思?例如,你的意思是你的SQL Server複製配置的細節? – 2009-06-30 20:40:00

回答

1

AFIK沒有這樣做的標準方法。作爲技術的複製早於XML,其工具集和元數據不是以XML爲中心的。但是,與複製相關的所有內容都存儲在表的某處,無論是在主數據庫還是在msdb或分發數據庫中,請參見Replication Tables topic on MSDN或複製DMV(sys.dm_repl_articlessys.dm_repl_schemas)。所有這些信息都可以用XML格式化和格式化,但我不知道覆蓋這些信息的任何標準XML模式。

0

Remus的回答非常好。這是我用來將它導出到XML的SQL腳本。希望它對其他人有用:

DECLARE @PublicationId INT 
SET @PublicationId = 1 –- Use your publication ID here. Use SELECT * FROM syspublications to see a list of publications 

select 
     Publication.name AS [Name] 
     , Publication.description AS [Description] 
     , Article.name AS [Name] 
     , Article.dest_table AS [Table] 
     , [Column].name AS [Name] 
     , [Column].[Type] 
     , [Column].MaxLength 
     , [Column].Nullable 
from dbo.syspublications Publication 
     join dbo.sysarticles Article on Publication.pubid = Article.pubid 
      join sys.tables st on st.object_id = Article.objid 
     join dbo.sysarticlecolumns ac on Article.artid = ac.artid 
     join 
     (
      select 
        sc.object_id 
        , sc.column_id 
        , sc.name AS [Name] 
        , sty.name AS [Type] 
        , sc.max_length AS MaxLength 
        , sc.is_nullable AS Nullable 
      from dbo.syspublications p 
        join dbo.sysarticles a on p.pubid = a.pubid 
        join dbo.sysarticlecolumns ac on a.artid = ac.artid 
         join sys.columns sc on sc.object_id = a.objid AND sc.column_id = ac.colid 
        join sys.types sty on sty.user_type_id = sc.user_type_id 
      where p.pubid = @PublicationId 
    ) [Column] on [Column].object_id = Article.objid AND [Column].column_id = ac.colid 
where Publication.pubid = @PublicationId FOR XML AUTO