A questionon FOR JSON to delegate the JSON formatting to SQL Server -


the following statement retrieves data odata service in sql server 2016 when database context set adventureworks2014:

 select 'http://services.odata.org/v4/northwind/northwind.svc/$metadata#products(productid,productname)/$entity'  '@odata.context', productid, name productname    production.product  productid <400 json auto   

when 'master' context, returns error. however, northwind not present in sql server 2016 on instance of sql server 2012 on same windows 10 machine.

why did work when database context running query 'adventureworks 2014'?

the above query link: https://msdn.microsoft.com/en-us/library/dn921897.aspx

if master current database, query try find production.product table in master database , fail because there no such kind of table there. should switch context of query database table placed, or use 3 part name explicit database name, e.g.:

select 'http://services.odata.org/v4/northwind/northwind.svc/$metadata#products(productid,productname)/$entity'  '@odata.context', productid, name productname    adventureworks2014.production.product  productid <400 json auto  

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -