Reputation: 663
Could anyone please say me how to declare a column of xml type in sql azure table and also how to save that file from a local computer to the sql azure table?
Thanks in advance :)
Upvotes: 1
Views: 1282
Reputation: 2898
Here is the short answer:
USE YourDataBaseName
GO
CREATE TABLE Something
([SomethingID] INT PRIMARY KEY IDENTITY,
[TheColumnYouWantToDeclare] XML)
GO
With EntityFramework and LINQ to SQL, you can read the xml content and save that to the column. Here is how you can do this. Of course, you can also write SQL queries but here is how I just solved the problem with LINQPAD.
var myEntityToAdd = new Something();
var xmlContent = System.IO.File.ReadAllText(@"C:\NameOfFile.xml");
var xdoc = XDocument.Parse(xmlContent).Root;
myEntityToAdd.TheColumnYouWantToDeclare = xdoc;
Somethings.InsertOnSubmit(myEntityToAdd);
SubmitChanges();
In Azure SQL tables, you can do a lot of things with XML. Here are three videos to help you:
https://channel9.msdn.com/Series/Using-XML-in-SQL-Server-and-Azure-SQL-Database/01 https://channel9.msdn.com/Series/Using-XML-in-SQL-Server-and-Azure-SQL-Database/02 https://channel9.msdn.com/Series/Using-XML-in-SQL-Server-and-Azure-SQL-Database/03
Upvotes: 0
Reputation: 9680
Not the exact answer you are looking for but here what you can do,
BLOB
, instead Azure Table. BLOB
is structure designed for this purpose only.BLOB
url in your Azure Table.Hope this helps you.
Upvotes: 1