Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import .dbf file

Status
Not open for further replies.

zlaja

Programmer
Oct 1, 2001
14
CA
I would like import data from .dbf file to SQL server. For that I tray to use bulk copy utility but it doesn't work. I exported my .dbf file to ascci file and I use this statment to export this .txt file to Server SQL, but it doesn't work.What is wrong in my statement? Can someone help me?

bcp MyDataBase..MyTableSql in MyFile.txt -c -r\n -t" " -SMyServerName -UMyDataBaseName -PMyPassword

I appreciate any help
 
What error message are you getting? Is your text file SPACE delimited, TAB delimited, COMMA delimited, etc? Do you have permissions to write to the table? Not sure without the actual error message. You might try this:

bcp MyDataBase..MyTableSql in c:\mydir\MyFile.txt -c -r\n -t" " -SMyServerName -UMyDataBaseName -PMyPassword

Hope this helps.
 
The message is : Microsoft ODBC SQL server driver: string data, right truncation bcp copy in failed.

My text file type is - fixed (with delphi I exported my .dbf file to assci file)

Yes, I have permission to write in the table.
 
If your input file is fixed width, then you will probably want to use a format file. Try this:

bcp MyDataBase..MyTableSql in MyFile.txt -SMyServerName -UMyDataBaseName -PMyPassword

This should then prompt you for a format file.

Hope this helps.
 
I tried this statment, it works but I would like put this statment in batch file and execute this every morning automatically to transfer my data from one server to another. If my programme will be prompted with all this questions for format file it will be very unplesant for users.

Thanks anyway!
 
When you went through all the prompts, it asked if you wanted to save the format file. You simply save the format file and use it in your bcp statement.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top