Tutorial by Examples

You can customize parsing rules using different options in WITH clause: BULK INSERT People FROM 'f:\orders\people.csv' WITH ( CODEPAGE = '65001', FIELDTERMINATOR =',', ROWTERMINATOR ='\n' ); In this example, CODEPAGE specifies that a source file in UTF-8 f...
BULK INSERT command can be used to import file into SQL Server: BULK INSERT People FROM 'f:\orders\people.csv' BULK INSERT command will map columns in files with columns in target table.
You can read content of file using OPENROWSET(BULK) function and store content in some table: INSERT INTO myTable(content) SELECT BulkColumn FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document; SINGLE_BLOB option will read entire content from a file as single cell. ...
Yu can define format of the file that will be imported using FORMATFILE option: INSERT INTO mytable SELECT a.* FROM OPENROWSET(BULK 'c:\test\values.txt', FORMATFILE = 'c:\test\values.fmt') AS a; The format file, format_file.fmt, describes the columns in values.txt: 9.0 2 1 SQ...
You can use OPENROWSET to read content of file and pass it to some other function that will parse results. The following example shows hot to read entire content of JSON file using OPENROWSET(BULK) and then provide BulkColumn to OPENJSON function that will parse JSON and return columns: SELECT boo...

Page 1 of 1