Solved

BCP Function Problem

Posted on 2006-06-28
5
316 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 36
Sql server function help 15 31
SQL Update trigger 5 18
Passing Parameter to Stored Procedure 4 24
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

777 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