SQL Server Bulk Insert Update from CSV? -


i'm importing csv file sql server. problem need update if rows found, haven't found insert update equivalent or similar it.

this current code:

bulk insert actuals_financials_temp '\\strmv3302\temp\actuals_financials_temp.csv'   (fieldterminator = ',', rowterminator = '\n', firstrow = 2) 

is there way update rows matching keys? or @ least ignore them rest uploaded , bulk update?

not directly, no. need bulk insert staging table , update existing records , insert missing records. try local temp table (i.e. #tablename) first.

technically speaking, either of following (both of use openrowset):

  • skip staging table , use openrowset(bulk...) update , insert queries. have tested, though, see if cost of reading file twice worth savings of not having read temp table (which writes disk). possible using staging table might still better since first query, update, might auto-create statistics benefit second query, insert, since query need either left join or where not exists.
  • merge along openrowset(bulk...), merge has "issues" wouldn't try this.

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -