1

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 :)

2 Answers 2

1

Not the exact answer you are looking for but here what you can do,

  1. Save the file in BLOB, instead Azure Table. BLOB is structure designed for this purpose only.
  2. Secondly, you can store the BLOB url in your Azure Table.
  3. This will make your application easy to understand and also easy to implement.
  4. This will also help in reducing the size of your database, smaller database better performance

Hope this helps you.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your information. Could you please tell me how to create a blob and save a file?
Check this sample on MSDN. Or debugmode.net/2011/09/01/… . You can make BLOB public or private. Generally images are stored in Public blob, so that they can be directly download from client machine. In application you can use WebClient to fetch file from BLOB. Also if you are satisfied with answer, accept them, please read FAQ. You didn't accept any answer on your questions.
Thank you very much Amar Palsapure. Really the post helped me a lot.
Glad it worked for you. If you are satisfied with the answer, click "Check Icon" below the up and down arrows, and then click uparrow. This way it helps others in understanding which is the correct answer. There is Accept-Rate associated, if that is low guys on SO wouldn't answer your question. Please read the FAQ.
Why BLOB? XML = XML Right? This query creates an XML column: USE YourDataBaseName GO CREATE TABLE Something ([SomethingID] INT PRIMARY KEY IDENTITY, [TheColumnYouWantToDeclare] XML) GO
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.