Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

CLR procedure to export xml file ? Expand / Collapse
Author
Message
Posted Wednesday, December 21, 2011 5:26 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, December 21, 2011 6:17 PM
Points: 5, Visits: 9
GSquared (12/21/2011)
I'm not exactly expert at CLR, but I've bumbled my way through writing a text file using VB.NET's file operations just by digging through Bing searches on the subject. It's not that hard to do. I can't remember how I did it (was 3 years ago), but I remember it not being particularly difficult. Writing an XML file should be easy enough, unless you have oddball requirements.

Have you thought about simply having SSIS export the file instead? That'll be even easier.

thank you


Cadavre (12/21/2011)
Totally untested, I'm not at my desk any more.

using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
using System;
using System.IO;

namespace XMLWriter
{
public class XMLWriter
{
[SqlFunction]
public static SqlString ReplaceMatch(
SqlString inputXMLString,
SqlString outputFileDIR)
{
try
{
// input parameters must not be NULL
if (!inputXMLString.IsNull &&
!outputFileDIR.IsNull)
{
System.IO.StreamWriter file = new System.IO.StreamWriter(outputFileDIR);
file.WriteLine(inputXMLString);
file.Close();
}
else
// if any input paramater is NULL, return NULL
return SqlString.Null;
}
catch
{
// on any error, return NULL
return SqlString.Null;
}
return new SqlString();
}
};
}


will give it a try thx buddy :)
Post #1225506
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse