bulkinsert - sql server bulk insert and temporary tables -
ive been learning mysql decided have attempt @ sql server. have pasted code mysql sql server , figuring out parts of code need adapted work in sql server. trying create temporary table , bulk insert text file temporary table. statement works fine in mysql show:
create temporary table test123 ( reason_t varchar(30) default null, month_t varchar(30) default null, year_t varchar(30) default null, week_type_t varchar(30) default null, accident_time_t varchar(30) default null, alcohol_level_t varchar(30) default null, age_t varchar(30) default null, gender_t varchar(30) default null); load data local infile 'c:\\users\\jon\\onedrive\\desktop\\roadsafety_test123.txt' table test123 fields terminated ',' lines starting '' terminated '\r\n' ignore 1 lines;
and in sql server have far come this:
declare @test123 table ( reason_t varchar(30) default null, month_t varchar(30) default null, year_t varchar(30) default null, week_type_t varchar(30) default null, accident_time_t varchar(30) default null, alcohol_level_t varchar(30) default null, age_t varchar(30) default null, gender_t varchar(30) default null); bulk insert test123 'c:\\users\\jon\\onedrive\\desktop\\roadsafety_test123.txt' ( fieldterminator =',', firstrow = 2, rowterminator = '\n');
the query in sql server not work however, temporary table actions don't seem straight forward mysql , im struggling find relevant information regarding it. did aswell try creating test123 table standard create table statement insert still got error 4863 age_t column in test123, far data goes see no problems , works fine in mysql.
i'm sure have missed obvious or done wrong way round said have never used sql server before can't find definitive answers.
you should provide @ least few lines of file use import, might others pinpoint causing error. :)
bulk insert test123 'c:\\users\\jon\\onedrive\\desktop\\roadsafety_test123.txt' (fieldterminator =',', firstrow = 2);
just idea, try removing "rowterminator = '\n'" part of code. bulk insert in sql server treats "end-of-line" default row terminator. , read somewhere windows text files uses different end-of-line symbols, cr lf, mark end of row. though can't find reference, can see opening text file notepad++, click view tab, show symbol, ticking show end-of-line.
Comments
Post a Comment