|
How can I insert data into a table that uses a different number of columns than my table?
(9324 Requests)
You have to specify a colpattern. Follow this link and
scroll down to section B.
Feedback
# Problem if using a Where clause
11/15/2001 8:19 AM
Brett Morgan
While the colpattern works great if you want to select all the columns, it breaks down when you have a Where clause. You can't have a column in the where clause that is not in your colpattern, so you resultset will include this column, therefore is won't insert. I got around this by inserting into a temp table and then selecting want I needed from that. Not idea.
# Problem if using a Where clause
11/15/2001 9:50 PM
Bryant
To get around the limitation of having to specify a column that you don't want to insert, you can filter out the values you don't want by using XPath. See this faq for more info: http://sqlxml.org/sqlxml/faqs.xml?faq=60
# Problem if using a Where clause
8/27/2002 2:15 PM
Simon
I would strongly recommend that an filtering on the XML should be done in the rowpattern. The performance of the OPENXML statement is directly related to the rows returned and the columns returned
# Problem if using a Where clause
8/27/2002 2:17 PM
Simon
Further more you can still return a column in the OPENXML rowset and not specify it in the SELECT clause, i.e do not use SELECT *
# re: How can I insert data into a table that uses a different number of columns than my table?
9/29/2006 3:44 PM
dude
The link to the doc is broken.
dhqr efbakmx fnmzgopwq hrcdg jdcakt toun suvpa
|