Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: 
 SQL Server 2017 (14.x) and later  
 Azure SQL Database 
 Azure SQL Managed Instance
Returns the character representation (JSON) of the node ID for a given object ID and graph ID.
Syntax
NODE_ID_FROM_PARTS ( object_id, graph_id )
Arguments
object_id
An int representing the object ID for the node table.
graph_id
A bigint value for the graph ID for a node.
Return value
Returns an nvarchar(1000) character representation (JSON) of the node ID. The return value can be NULL if any of the supplied arguments are invalid.
Remarks
- The character representation (JSON) of the node ID returned by NODE_ID_FROM_PARTSis an implementation specific detail, and is subject to change.
- NODE_ID_FROM_PARTSis the only supported way to construct a suitable character representation of the node ID.
- NODE_ID_FROM_PARTSis useful for bulk inserting of data into a graph table, when the source data has a suitable natural or surrogate key with an integer data type.
- The value returned from NODE_ID_FROM_PARTScan be used to populate the$node_idcolumn in a node table. It can also be used to populate the$from_id/$to_idcolumns in an edge table.
- For NODE_ID_FROM_PARTSto return valid character representation (JSON) of a node ID, theobject_idparameter must correspond to an existing node table. Thegraph_idparameter can be any valid integer, but it need not exist in that node table. If any of these checks fail,NODE_ID_FROM_PARTSreturns NULL.
Examples
The following example uses the OPENROWSET Bulk Rowset Provider to retrieve the ID and name columns from a CSV file stored on an Azure Storage account. It then uses NODE_ID_FROM_PARTS to create the appropriate character representation of $node_id for eventual (bulk) insert into the Person node table. This transformed data is then (bulk) inserted into the Person node table.
INSERT INTO Person($node_id, ID, [name])
SELECT NODE_ID_FROM_PARTS(OBJECT_ID('Person'), ID) as node_id, ID, [name]
FROM OPENROWSET (BULK 'person_0_0.csv',
    DATA_SOURCE = 'staging_data_source',
    FORMATFILE = 'format-files/person.xml',
    FORMATFILE_DATA_SOURCE = 'format_files_source',
    FIRSTROW = 2) AS staging_data;
;