SELECT CustomerName, PhoneNumber, FaxNumber
FROM Sales.Customers
FOR JSON PATH
FOR JSON PATH so'zi so'rov natijalarini JSON matni sifatida formatlaydi. Ustun nomlari kalit sifatida ishlatiladi va uyali qiymatlar JSON qiymatlari sifatida yaratiladi.
[
{"CustomerName":"Eric Torres","PhoneNumber":"(307) 555-0100","FaxNumber":"(307) 555-0101"},
{"CustomerName":"Cosmina Vlad","PhoneNumber":"(505) 555-0100","FaxNumber":"(505) 555-0101"},
{"CustomerName":"Bala Dixit","PhoneNumber":"(209) 555-0100","FaxNumber":"(209) 555-0101"}
]
Natija to'plami JSON massivi sifatida formatlanadi, har bir satr alohida JSON ob'ekti sifatida formatlanadi.
PATH ustunlar taxalluslarida nuqta belgisi yordamida JSON natijalarining chiqish formatini sozlashingiz mumkinligini bildiradi. Quyidagi so'rov JSON formatidagi CustomerName kalit nomini o'zgartiradi va telefon va faks raqamlarini Cantact ichki ob'ektiga qo'yadi.
SELECT CustomerName as Name, PhoneNumber as [Contact.Phone], FaxNumber as [Contact.Fax]
Dostları ilə paylaş: |