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 🙂