I have a dataset more than 1000 when import into SSMS. Thus I use the following T-SQL to create table and import data:
CREATE TABLE sales(
SPID text,
GeoID text,
PID text,
SaleDate smalldatetime,
Amount int,
Customers int,
Boxes int);
BULK INSERT sales
FROM 'C:\Users\alvin_zoj6s4b\Downloads\sales.txt'
WITH (FIELDQUOTE = '\'
, FIELDTERMINATOR = ','
, ROWTERMINATOR = '\n');
The problem is on the SalesDate column so I change from smalldatetime to Text on create table query:
CREATE TABLE sales(
SPID text,
GeoID text,
PID text,
SaleDate TEXT,
Amount int,
Customers int,
Boxes int);
The result of the table showing ' ' on the text data type (SPID, GeoID, PID & SaleDate):
Here is the structure of my text file stored in my laptop:
The 2 problems I would like to clarify:
- Text data type should put ' ' in the raw data when import the data to SSMS but why my output will showing ' '?
- The SaleDate only work when I change it to text, anything I have done wrongly?