sql-serverxmlnode

Does Selecting from XMLNodes Count as 3-Part Naming Convention in SQL Server?


I recently saw a comment from @Larnu highlighting that 3+ part naming on columns will soon(ish) be depreciated. There was a link to a useful article on his website which details about this:

https://wp.larnu.uk/3-part-naming-on-columns-will-be-deprecated/

Specifically, it quotes from the depreciated SQL Server features page on learn.microsoft.com (https://learn.microsoft.com/en-us/sql/database-engine/deprecated-database-engine-features-in-sql-server-2016?view=sql-server-ver15):

The following SQL Server Database Engine features are supported in the next version of SQL Server, but will be deprecated in a later version. The specific version of SQL Server has not been determined:

Category Deprecated feature Replacement Feature name Feature ID
Transact-SQL Three-part and four-part column references. Two-part names is the standard-compliant behavior. More than two-part column name 3

My question is does this apply to when using XMLnodes as a column reference? e.g.:

SELECT
    XMLNodes.x.value('@time', 'datetime') as Runtime,
    InnerXMLNode.x.value('@currency', 'varchar(3)') as Currency,
    InnerXMLNode.x.value('@rate', 'Decimal(10,7)') as Rate
from
    @xmlFile.nodes('/Envelope/Cube/Cube') as XMLNodes(x)
    cross apply XMLNodes.x.nodes('Cube') as InnerXMLNode(x)

I can't find anything specifically excluding XMLnodes, but are they technically still columns? If the depreciated feature does include XMLnodes, how do you do this without 3+ part naming?


Solution

  • No, the 3+ part naming means when you are naming the object names, for example SchemaName.TableName.ColumnName, that isn't the case in the above.

    XMLNodes is the table name, and x the column, however, value is a method of the xml type (basically a function), not an object. So you are using 2 part naming, and then using a method extension of the xml type, just like you are in the FROM for nodes (XMLNodes.x.nodes).