Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 461795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:00:37+00:00 2026-05-12T23:00:37+00:00

I am working on a WPF application for a vertical market. In a discussion

  • 0

I am working on a WPF application for a vertical market. In a discussion today about how to build the data structure to support the selection of a dozen checkboxes and radio buttons, I thought about the possibility of serializing an object to XML and storing that in SQL Server, then deserializing it when the data needs to be displayed.

My question is about storing XML in SQL Server 2008. My colleagues think this approach is a bad idea and put forward the possibility of using a generic list table that stores data in name-value pairs.

What are the pros and cons of storing XML data in SQL Server 2008? Am I out of my mind on this, or am I on to something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:00:38+00:00Added an answer on May 12, 2026 at 11:00 pm

    Space Usage

    XML storage takes less space compared to the NVARCHAR(N) storage. One of the reasons for this is that, the XML data type converts element/attribute names to internal identifiers and store the ID instead of the element name. This saves lot of storage space.

    For example, look at the below example:

    DECLARE @x NVARCHAR(MAX)
    SELECT @x = '
      <Employees>
        <EmployeeFirstNameLastNameandMiddleName>Jacob v Sebastian</EmmployeeFirstNameLastNameandMiddleName>
        <EmployeeFirstNameLastNameandMiddleName>Someone x somewhere</EmployeeFirstNameLastNameandMiddleName>
      </Employees>'
    

    The test:

    SELECT DATALENGTH(@x) AS Length
    

    Result:

    Length
    ------
    498
    

    …versus:

    DECLARE @x1 AS XML
    SELECT @x1 = CAST(@x AS XML)
    SELECT DATALENGTH(@x1) AS Length
    

    Result:

    Length
    ------
    218
    

    Note that the NVARCHAR version took 498 bytes and XML version took only 218 bytes.

    Performance

    Generally speaking, XML might give you better performance. However, it depends on the usage of the data. If you need to query the XML value and extract the information from nodes/attributes, XML will give you the best performance. If you use NVARCHAR, you will need to convert the value to XML at runtime and this will add overhead to the query processor.

    Secondly, less size means less IO needed while reading and writing. This can directly translate to performance gains.

    If you store the data just for the sake of storing, and no query operations are done inside the XML document, It might be a better choice to store the data as VARBINARY. This might give better performance as SQL Server does not need to perform the XML related validations and formatting while storing and reading data.

    NVARCHAR vs VARBINARY

    If you don’t want to store the data as XML, your next best option is VARBINARY(MAX). Storing the values in NVARCHAR can cause you encoding related problems.

    Taken from the post here.


    I have to admit, for the sake of dynamically laying out forms, it will be far less of a pain to administrate via xml, which you can store in the db, rather than using a key/value pair in the db.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a wpf application. I am copying the data to excel
I'm working on a WPF application and struggling with a data trigger. I'd like
Working with a WPF application. I am very much wonderin if it is possible
I'm working on a WPF application that sometimes exhibits odd problems and appears to
I'm working on a WPF application and is using the Model-View-ViewModel pattern. The application
I am working on a WPF application which has a treeview that represents an
I'm working on a WPF application, and I'm structuring it using the MVVM pattern.
I'm working on a WPF application which should be utilizable with two monitors. In
I am working on a wpf application. Here I need to use System.Windows.Forms.FolderBrowserDialog in
I'm working on a WPF application that contains a wrapper UI that is actually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.