I want to read an XLSX file into XML and the pass this XML to a stored procedure and read this xml inside the SP and insert records from the XML to a table.
here is my C# code
FileStream stream = File.Open(FilePath, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet result = excelReader.AsDataSet();
excelReader.IsFirstRowAsColumnNames = true;
string xmlDS = result.GetXml();
I will pass xmlDS as string to the SP. Now I need a SP to read this file and insert data into a table.
you can use OPENXML that provides a rowset view over an XML document
for more info:
http://msdn.microsoft.com/en-us/library/ms186918.aspx
then you can use the SELECT to insert your data as showed here