sql server import json 1

sql server import json

DECLARE @JSON VARCHAR(MAX)

SELECT @JSON = BulkColumn
FROM OPENROWSET 
(BULK 'C:\file-location\my-data.json', SINGLE_CLOB) 
AS j

Here is what the above code is Doing:
1. Declaring a variable called @JSON
2. Using OPENROWSET to read the file into the variable
3. The file path is the first parameter
4. The second parameter is set to SINGLE_CLOB. This is important because it allows us to read the entire file into the variable.

Similar Posts