Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

MSH host function in SQL server 2005

// part of a sql server CLR function, and example of hosting MSH in sql server 2005
   1  
   2      [Microsoft.SqlServer.Server.SqlFunction]
   3      public static SqlString sqlmsh(string input)
   4      {
   5          string output;
   6          Runspace runspace = RunspaceFactory.CreateRunspace();
   7          runspace.Open();
   8          Pipeline pipeline = runspace.CreatePipeline(input);
   9          MshObject myobj =   pipeline.Invoke()[0];
  10          if (myobj.BaseObject is XmlDocument)
  11           {
  12              output = (myobj.BaseObject as XmlDocument).InnerXml;
  13          } else
  14              output = myobj.ImmediateBaseObject.ToString();
  15              
  16          runspace.Close();
  17          return new SqlString(output);
  18      }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS