-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_Extract_Data.sql
More file actions
35 lines (31 loc) · 982 Bytes
/
1_Extract_Data.sql
File metadata and controls
35 lines (31 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
==============================================================
EXTRACTING DATA
==============================================================
1. Script Purpose:
This script creates a new table for the dataset and then insert the dataset into the created table using 'BULK INSERT'
*/
USE MyDatabase
-- Create the table
CREATE TABLE raw_audible_book (
name NVARCHAR(300),
author NVARCHAR(150),
narrator NVARCHAR(150),
time NVARCHAR(50),
release_date NVARCHAR(50),
language NVARCHAR(50),
stars NVARCHAR(50),
price NVARCHAR(50)
)
-- Bulk Insert dataset into the table
BULK INSERT raw_audible_book
FROM 'C:\Users\harto\OneDrive\Dokumen\DATA ANALYST PORTOFOLIO PROJECT\5. Audible Book Data Cleaning With SQL\archive (5)\audible_uncleaned.csv'
WITH (
FORMAT = 'CSV',
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '0x0a',
TABLOCK,
CODEPAGE = '65001', -- UTF-8 encoding
DATAFILETYPE = 'char' -- ensure text is treated properly
);