sql server - sql custom bulk insert -
i have big files (aprox. 50.000 rows) lot of columns (450 columns) want bulk insert , thing want 220 of them inserted. there way can sql without using backend processing ?
the file
123434|s2231|1|||0|inet|20150511123344|...........1233123|12|0
and star_date
field in db datetime
, in .csv date comes 20150511123344
(yyyymmmddhhmmss format) best way insert without preprocessing (2015-05-11 12:33:44) ?
thank much
you can use openrowset bulk rowset provider.
here sample link:
use adventureworks2012; delete mytestformatfiles; go insert mytestformatfiles select * openrowset(bulk 'c:\mytestformatfiles-c.dat', formatfile='c:\mytestformatfiles.xml' ) t1 ; go select * mytestformatfiles; go
in case, replace "select *" column list. may or may not need format file, try without first.
given table has 400+ columns, can generate format file using bcp.exe, assuming have access server , table bcp file generated from.
sample command line generate format file native data types:
bcp adventureworks2012.humanresources.department format nul -t -n -f department-n.fmt
once format file has been created, can open file see column names, build column list select statement.
Comments
Post a Comment