简体   繁体   中英

Importing File to SQL Server

I have a comma delimited file which I want to import into SQL Server.

The file is quite huge (240MB).

I need to import the same via the following process:

  1. Create table to import to.
  2. The first line of the file would correspond to the column of the table.
  3. All items would be treated as string.

Is there a tool in SQL server specifically designed to do this?

Thanks.

Ok,

Use the SQL Server Import and Export Wizard,

  • Set the Data Source to Flat File Source
  • Browse your CSV File
  • Check the check box "Column names in the first data row"
  • Check out the preview to see if that's the result you want.

Good luck.

If its just a one-off file, then use what used to be called DTS, now commonly referred to as the SQL Server Import/Export Wizard.

BCP is probably a bit more complicated to set up and get going for a one-off file, but if you're doing this often, then learn and use BCP.

In the Import/Export wizard there is a checkbox on the Choosa a Data Source screen, at the General tab called 'Column names in the first data row'; that will let you have the first row as a header row.

treating all items as string is fine, Import/Export wizard sets columns to string by default, with a width of 50, so you might want to increase it slightly if your data is going to be wider than that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM