1- /* *******************************************************************************
1+
2+ -- /********************************************************************************
23* Note: You can export file and create format file using bcp out command:
34*
45* > bcp " SELECT Name, Color, Price, Size, Quantity, Data, Tags FROM Product" queryout product .dat - d ProductCatalog - T
@@ -46,16 +47,17 @@ WITH ( TYPE = BLOB_STORAGE,
4647
4748DROP TABLE IF EXISTS Product;
4849GO
49-
50+ -- Create a permanent table. A temp table currently is not supported for BULK INSERT, although it will will work
51+ -- with OPENROWSET
5052CREATE TABLE dbo .Product (
5153 Name nvarchar (50 ) NOT NULL ,
5254 Color nvarchar (15 ) NULL ,
5355 Price money NOT NULL ,
5456 Size nvarchar (5 ) NULL ,
5557 Quantity int NULL ,
5658 Data nvarchar (4000 ) NULL ,
57- Tags nvarchar (4000 ) NULL ,
58- INDEX cci CLUSTERED COLUMNSTORE
59+ Tags nvarchar (4000 ) NULL
60+ -- , INDEX cci CLUSTERED COLUMNSTORE
5961)
6062GO
6163
@@ -69,6 +71,7 @@ FROM 'product.csv'
6971WITH ( DATA_SOURCE = ' MyAzureBlobStorage' ,
7072 FORMAT = ' CSV' , CODEPAGE = 65001 , -- UTF-8 encoding
7173 FIRSTROW = 2 ,
74+ ROWTERMINATOR = ' 0x0a' ,
7275 TABLOCK );
7376
7477-- 2.2. INSERT file exported using bcp.exe into Product table
@@ -93,4 +96,4 @@ FROM OPENROWSET(BULK 'product.bcp',
9396 DATA_SOURCE = ' MyAzureBlobStorage' ,
9497 FORMATFILE = ' data/product.fmt' ,
9598 FORMATFILE_DATA_SOURCE = ' MyAzureBlobStorage' ) as data
96- GROUP BY Color;
99+ GROUP BY Color;
0 commit comments