Solved

BCP Function Problem

Posted on 2006-06-28
5
312 Views
Last Modified: 2012-08-14
Hi guys,

I've recently found out about the command prompt function BCP.

I am testing it out, and am able to export data to a file using this:

BCP Northwind.dbo.Categories out c:\categories.txt -n -Smyservername -Uusername -Ppassword

and it works fine, as it outputs this:

Starting copy...
8 rows copied.

So I now want to import the data back into the database, so I use this:

BCP Northwind.dbo.Categories in c:\categories.txt -c -Smyservername -Uusername - Ppassword

and when I run that, it returns the following error:

Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft]pODBC SQL Server Driver]Unexpected EOF encountered in BCP data-file
0 rows copied.



What am I doing wrong?

Cheers guys!
0
Comment
Question by:Cyber-Drugs
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 16999826
   
Cyber-Drugs,
> BCP Northwind.dbo.Categories in c:\categories.txt -c -Smyservername  -Uusername - Ppassword

Change 'c' char type to native type(n) and test


BCP Northwind.dbo.Categories in c:\categories.txt -n   -Smyservername  -Uusername - Ppassword


0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 16999890
AHA, works a charm now.

Before I set this question as answered, could you quickly let me know the difference between -c and -n, and which is better for which situation?

Thanks again aneeshattingal!
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16999927
its described in Books online
bcp utiliy-> parameters


mk:@MSITStore:C:\Program%20Files\Microsoft%20SQL%20Server\80\Tools\Books\adminsql.chm::/ad_impt_bcp_3vqr.htm

0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16999971
also you copied data from the table as 'native' format
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 17000059
Perfect, thanks again! :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now