SELECT FOR XML AUTO and return datatypes

后端 未结 2 1963
灰色年华
灰色年华 2021-02-20 10:27

During playing with sys.dm_exec_describe_first_result_set I get to this point:

CREATE TABLE #tab(col INT, x XML );
INSERT INTO #tab(col,x) VALUES (1         


        
2条回答
  •  抹茶落季
    2021-02-20 11:03

    Interesting question! The NTEXT is really strange!

    I have an idea about the sub-query: When you return an XML it is ever transfered as string, unless you specify TYPE (You surely know this from nested XML with CROSS APPLY or from string concatenation with STUFF, where you somethimes see this with TYPEand a follwing .value() - and sometimes "naked".

    I could not really reproduce your results (SQL Server 2012 too). Simple copy'n'paste comes back with (I wanted to test with declared table variable and return value of a function):

    Simple XML              NULL                  NULL
    Wrapped with subquery   NULL                  NULL
    XML column              NULL                  NULL
    Casted XML              x                     xml
    Wrapped Casted XML      wrapped               xml
    Text value              text_string           ntext
    Wrapped Text Value      text_string_wrapped   ntext
    

    EDIT: There was a new observation I thought was unclear, but it was my mistake... Took it away...

提交回复
热议问题