May 31, 2016 at 8:17 pm
Comments posted to this topic are about the item Inserting XML
May 31, 2016 at 8:42 pm
I don't know why you get an error. This code
CREATE TABLE Mytest (id INT, x XML)
INSERT mytest
VALUES
(1, CAST('1200' AS XML))
, (2, CAST( '1201' AS XML))
... works just fine on my system.
-- Itzik Ben-Gan 2001
May 31, 2016 at 9:36 pm
Alan.B (5/31/2016)
I don't know why you get an error. This code
CREATE TABLE Mytest (id INT, x XML)
INSERT mytest
VALUES
(1, CAST('1200' AS XML))
, (2, CAST( '1201' AS XML))
... works just fine on my system.
Agreed. No error in that code.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 31, 2016 at 11:27 pm
There is no error in this code
May 31, 2016 at 11:49 pm
darkunic (5/31/2016)
There is no error in this code
Agreed and that is why I read the question again. The question seemed more about 'how do I use this data to create an XML document?' rather than the code itself, so was there something else missing?
Luckily got it right after reading the Stairway to XML articles.
...
June 1, 2016 at 12:01 am
me too found no error with this code.
June 1, 2016 at 1:31 am
Works fine for me too!
June 1, 2016 at 1:38 am
Alan.B (5/31/2016)
I don't know why you get an error. This code
CREATE TABLE Mytest (id INT, x XML)
INSERT mytest
VALUES
(1, CAST('1200' AS XML))
, (2, CAST( '1201' AS XML))
... works just fine on my system.
works fine on at least the last three versions of sql server.
Igor Micev,My blog: www.igormicev.com
June 1, 2016 at 1:51 am
I guessed the first option (about the = sign) as there was obviously something wrong with the question (the SQL will run fine) so I guessed that the typo was the omission of an '=' somewhere.
Close, but no cigar 😉
June 1, 2016 at 2:00 am
Don't even know why I bothered answering this one - it was a pure guess, given that I didn't even understand half of the options, and the code doesn't cause an error!
The explanation "The XML document needs to attribute for ID to be quoted" also doesn't make much sense, nor does it seem to relate to the question.
Try again!
June 1, 2016 at 2:03 am
Another borked QotD.
June 1, 2016 at 2:43 am
Same here, no errors in the code.
June 1, 2016 at 3:00 am
should the code have been
CREATE TABLE Mytest (id XML, x XML)
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
June 1, 2016 at 3:01 am
Don't know what the question should have been for that set of answers. Certainly not an error. +1
June 1, 2016 at 3:05 am
Choose the "correct" answer by eliminating the ones that were definitely correct.
Agree with the rest, code is working and no error occurs. A bit strange though, because according to me the values are not well formed XML.
From BOL
Well-formed XML and the xml Data Type
The xml data type implements the ISO standard xml data type. Therefore, it can store well-formed XML version 1.0 documents and also so-called XML content fragments with text nodes and an arbitrary number of top-level elements in an untyped XML column. The system checks that the data is well-formed, does not require the column to be bound to XML schemas, and rejects data that is not well-formed in the extended sense. This is true also of untyped XML variables and parameters.
Viewing 15 posts - 1 through 15 (of 36 total)
You must be logged in to reply to this topic. Login to reply