Solved

BCP and bulk insert questions

Posted on 2013-11-18
4
356 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:Scott Pletcher
Scott Pletcher 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help Required 3 97
Sql server get data from a usp to use in a usp 5 16
Help in Bulk Insert 9 35
Alternative of IN Clause in SQL Server 3 21
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

809 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