can sql server add columns dynamically

  • I have XML files that need to be put into a table. The problem is that the nodes can range from 1 to ? and inside of some of those nodes some data changes from time to time. usually by one item. So I know how to put a defined amount in database and here I need to be able to change the columns on the fly for any XML document. Can I create columns dynamically each time I load an XML file into a SQL table?

  • With SELECT...INTO... you can create a table with the needed columns. However, what would you do next with that data? I assume that you'll insert base columns onto a table. What will you do with the changes in the XML file? How would you handle them?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • I'm looking to see if I can add columns dynamically to a SQL table

  • Yes, you can do it with dynamic sql. The question is why would you do that.

    Altering the schema to fit an xml file is wrong and should be done the other way around. You should transform your xml file to fit your predefined schema.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply