Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

BCP Function Problem

Posted on 2006-06-28
5
Medium Priority
?
328 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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

824 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