lundi 29 juin 2015

Importing txt file to sql server without mentioning data types of each column

while importing any txt file to sql server, i create an empty table first by mentioning data structure (variable names and their data type) and then copying data into this empty table from text file. Following is the query which i use.

CREATE TABLE test ( account_id varchar(20), target integer, ttl_spend_bp_8m numeric(38,4), trns_bp_fuel_8m bigint );

COPY test FROM 's3://acncrmbpmanalytics/PT/sc_feb_jfr_final_population.txt' WITH CREDENTIALS AS 'xxxxxxxxxx' IGNOREHEADER 1 maxerror 1000 delimiter '\t' DATEFORMAT 'YYYY-MM-DD' TIMEFORMAT 'YYYY-MM-DD HH:Mi:SS' COMPUPDATE ON;

But this time i have a txt file having 255 variables and i do not know data types of these variables. How should i import this table to sql server?

Aucun commentaire:

Enregistrer un commentaire