Storing the text of a stored procedure in an XML data type in SQL Server

后端 未结 3 1146
故里飘歌
故里飘歌 2020-12-21 14:54

I need to store the text of all of the stored procedures in a database into an XML data type. When I use, FOR XML PATH, the text within in the stored procedure

3条回答
  •  滥情空心
    2020-12-21 15:36

        SELECT 
            1 as Tag,  
            0 as Parent,    
            [View].name AS 'StoredProcedure!1!Name', 
            [Module].definition AS 'StoredProcedure!1!Definition!cdata'     
        FROM sys.views AS [View] 
        INNER JOIN sys.sql_modules AS [Module] ON [Module].object_id = [View].object_id
        FOR XML EXPLICIT 
    

    Sample of the output from Adventureworks2012:

        
          
        
        
          
    

    As you note there are no / / "/ etc and NewLine characters is represented as new line

提交回复
热议问题