The NODE_ID_FROM_PARTS function

This function does an activity which is inverse to one of the previous functions. It generates a JSON conforming string for a given node_id from an object_id, with the help of the following code:

SELECT NODE_ID_FROM_PARTS(OBJECT_ID('dbo.TwitterUser'), 0);

It returns the JSON value that corresponds to the value for the first row in the dbo.TwitterUser node table, as shown in the following code:

-----------------------------------------------------------{"type":"node","schema":"dbo","table":"TwitterUser","id":0}

The function return NULL if a given object_id does not belong to a node table, as shown in the following code:

SELECT NODE_ID_FROM_PARTS(58, 0);

Here is the output:

---------NULL

The function returns  ...

Get SQL Server 2017 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.