Solved

BCP and bulk insert questions

Posted on 2013-11-18
4
351 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

758 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

23 Experts available now in Live!

Get 1:1 Help Now