I use SQL server 2005...
I have a tab delimited file which I want to import into my SQL server database.
My sql server table setup is:
CountryID int (autogenerated, identity specification)
CountryName nvarchar(40)
CountryAbbreviation nvarchar(3)
In my tab delimted file I have two columns:
CountryName and CountryAbbreviation
How can I best solve this?
If you use one version of SQL SERVER 2005 other than Express, you can use data import/Export Wizard to get the job done.
1.Right click on your database, select Task menu, click Import Data, the Wizard will start;
2.Click NEXT, you need choose a Data source. In your case, you choose the Flat File Source from the Data Source drowdown menu, then Browse to your text file. If you text file includes column names, you need check the checkbox infront of "Column names in the first data row"; click next;
3.You will see part of your data file in two clolumns, click Next;
4. Destination data base, use SQL Native Client (Default) as destination data source, pick your database from the Databasr dropdownlist, click next;
5.In this window, you will see both source and destination. You need pick your table from the destination column, click Edit button for mapping, make sure you match your source column with your destination column. (you cannot touch your identity field here) click next;
5. click next again, then click Finish. Data should be imported to your destination table along with their new ids.
I hope I make this process clear enough to follow.
Let me know if you are running into issues.
|||Great! explanation was clear enough :)It all works now!
No comments:
Post a Comment