Solved

BCP Function Problem

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

744 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

14 Experts available now in Live!

Get 1:1 Help Now