Solved

BCP and bulk insert questions

Posted on 2013-11-18
4
353 Views
Last Modified: 2013-11-25
I have a user who wants to bcp or bulk insert files from his local drive or from the share drive.

My expectation is that BCP can be done from his local command line, but we're having issue getting the syntax correct.

bcp inventory.dbo.fruits in "C:\fruit\inventory.txt" –Sservername -c -T

The other option we've considered is a bulk insert so he could call it from his SQL. Is there a way to refer to the Users C drive from within the SQL? We get error code 53 when we try to run it against the share drive.

What is the best approach?

Thanks
0
Comment
Question by:BillTr
4 Comments
 
LVL 12

Expert Comment

by:Tony303
ID: 39658297
How about using a UNC path?

Are the rights OK for the folder containg the Inventory.txt file?
0
 
LVL 1

Accepted Solution

by:
BradySQL earned 150 total points
ID: 39658409
You have to use a location that the SQL and the user that it is running as has access to. This means that only location local to SQL will be available if you are using a drive path like c:\ or E:\ otherwise you will have to give it the full share path to the file you wish to import, and make sure that the user that the SQL service is running as has access to it.

\\server\path\filename.txt
0
 

Author Comment

by:BillTr
ID: 39659259
If I reference drive c:\ from within SQL am I getting my local c drive? I thought that might be a c drive on the server...which I don't have access to.
0
 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 150 total points
ID: 39660058
>> If I reference drive c:\ from within SQL am I getting my local c drive? <<

No, you're getting the drive that the SQL installation sees as the C: drive.


You either have to map your local drive with a drive letter to SQL, and give the proper permissions to access it to the necessary login(s), or create a share and grant the necessary permissions to the share.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

867 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