sql bcp utility -in with xlsx ( Excel ) file

霸气de小男生 提交于 2019-12-13 05:00:14

问题


How to use bcp utility to import data from xlsx to sql database. When i tried to import it throws error saying 'String data, right truncation'. Do i need to specify any format or delimiters option explicitly? If I try to export the data from database as xlsx file and import that back to DB it works fine. but the exported file is not properly formatted as i try to open it with office excel it show up in some weird format.


回答1:


Don't use the xlsx file as it is, but save it in another format.

  1. You may save the xlsx as a comma separated or tab separated file.
  2. Specify the delimiter on the command line like this with a comma:

    bcp MySchema.dbo.[My Table] in MyCreatedCSVFile.csv -T -c -t,
    

One caveat: you may have your delimiter in your data file, in which case you will have to change your data or select a different delimiter.



来源:https://stackoverflow.com/questions/5190066/sql-bcp-utility-in-with-xlsx-excel-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!