| title | NODE_ID_FROM_PARTS (Transact-SQL) | ||
|---|---|---|---|
| description | NODE_ID_FROM_PARTS (Transact-SQL) | ||
| author | arvindshmicrosoft | ||
| ms.author | arvindsh | ||
| ms.date | 08/16/2022 | ||
| ms.service | sql | ||
| ms.subservice | t-sql | ||
| ms.topic | reference | ||
| ms.custom |
|
||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | =azuresqldb-current || >=sql-server-2017 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]
Returns the character representation (JSON) of the node ID for a given object ID and graph ID.
NODE_ID_FROM_PARTS ( object_id, graph_id )
An int representing the object ID for the node table.
A bigint value for the graph ID for a node.
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.
- 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.
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;
;