Kolom dengan nama yang ditentukan sebagai karakter kartubebas

Berlaku untuk:SQL ServerAzure SQL DatabaseAzure SQL Managed Instance

Jika nama kolom yang ditentukan adalah karakter kartubebas (*), konten kolom tersebut disisipkan seolah-olah tidak ada nama kolom yang ditentukan. Jika kolom ini adalah kolom tipe non-xml, konten kolom disisipkan sebagai simpul teks, seperti yang diperlihatkan dalam contoh berikut:

USE AdventureWorks2022;
GO
SELECT E.BusinessEntityID "@EmpID",
       FirstName "*",
       MiddleName "*",
       LastName "*"
FROM   HumanResources.Employee AS E
  INNER JOIN Person.Person AS P
    ON E.BusinessEntityID = P.BusinessEntityID
WHERE E.BusinessEntityID=1
FOR XML PATH;

Ini adalah hasilnya:

<row EmpID="1">KenJSánchez</row>

Jika kolom berjenis xml , pohon XML yang sesuai akan disisipkan. Misalnya, kueri berikut menentukan "*" untuk nama kolom yang berisi XML yang dikembalikan oleh XQuery terhadap kolom Instruksi.

SELECT
       ProductModelID,
       Name,
       Instructions.query('declare namespace MI="https://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
                /MI:root/MI:Location
              ') as "*"
FROM Production.ProductModel
WHERE ProductModelID=7
FOR XML PATH;

Ini adalah hasilnya. XML yang dikembalikan oleh XQuery dimasukkan tanpa elemen pembungkus.

<row>
  <ProductModelID>7</ProductModelID>
  <Name>HL Touring Frame</Name>
  <MI:Location LocationID="10">...</MI:Location>
  <MI:Location LocationID="20">...</MI:Location>
  ...
</row>

Baca juga