February 22, 2008 at 6:31 am
1. I just have modified my select statement a bit like iam just taking all now
means...
bcp "Select * from CurveTempDB.dbo.tLoanVectors where cusip='86359B6G1' " queryout C:\Sample.txt -T -c
for which am still getting the error...
Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file
Add the correct -S parameter ("Server\Instance")
Note: Iam not passing any -S, -U and -P for now. am running this as it is now. Kindy let me know if this is of any cause for the error and should I have to mention them while at desktop too.
2. Right now i am just runing this on my machine but later I need to run this on a server.
Your machine is the test server? Or are you just using your machine to connect to a test server?
3. Again, Sample.txt is right now on my desktop but yes it is supposed to be on the server.
Can't do anything here until question 2 is answered correctly.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 22, 2008 at 8:20 am
Jeff Moden (2/22/2008)
1. I just have modified my select statement a bit like iam just taking all nowmeans...
bcp "Select * from CurveTempDB.dbo.tLoanVectors where cusip='86359B6G1' " queryout C:\Sample.txt -T -c
for which am still getting the error...
Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file
Add the correct -S parameter ("Server\Instance")
Note: Iam not passing any -S, -U and -P for now. am running this as it is now. Kindy let me know if this is of any cause for the error and should I have to mention them while at desktop too.
2. Right now i am just runing this on my machine but later I need to run this on a server.
Your machine is the test server? Or are you just using your machine to connect to a test server?
3. Again, Sample.txt is right now on my desktop but yes it is supposed to be on the server.
Can't do anything here until question 2 is answered correctly.
Hi ,
When I kept a sub directory like (eg:C:\Test\Sample.txt), it worked for me where as if i keep directly the Directory path (eg:C\Sample.txt) it throws me that error.
Can any one tell me the reason why it just happens.
Thanks
February 22, 2008 at 8:29 am
The root directories of machines are usually secured more stringently than other folders. The proxy account doesn't have the permissions.
You running the BCP command from a command-line means that the command is done under your credentials. You running it from within a stored procedure means that it is NOT the same security context, and chances are very good that it's not being run under your account.
you need to look at what account starts SQL Server (the service), or the XP_CMDSHELL proxy account. Those are the two possible users under which this might be getting run. What THOSE accounts have access to (and what they don't have access to) is what is getting caught here.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
December 7, 2009 at 3:32 pm
Hey,
Can you travese to the exact BCP.EXE location under 80/90 //binn folder of microsoft sql server and then run the command. This should give you output.
Testcase
=====
1. In the command prompt enter Q:> BCP <enter>
check syntax is
usage: bcp [[database_name.]owner.]table_name[:slice_number] {in | out} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n] [-c] [-t field_terminator] [-r row_terminator]
[-U username] [-P password] [-I interfaces_file] [-S server]
[-a display_charset] [-q datafile_charset] [-z language] [-v]
[-A packet size] [-J client character set]
[-T text or image size] [-E] [-g id_start_value] [-N] [-X]
[-M LabelName LabelValue] [-labeled]
[-K keytab_file] [-R remote_server_principal] [-C]
[-V [security_options]] [-Z security_mechanism] [-Q] [-Y]
[-x trusted.txt_file]
2. IF I go to the exact location then i can see queryout
Q:\Program Files\Microsoft SQL Server\90\Tools\Binn>bcp
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-x generate xml format file]
Thanks
Anil G
Lina G
Database Administrator
August 11, 2011 at 4:45 am
Check in the control panel/ admin tools/Services
what account your sql server is running on. (could be network service account)
Then add that account to the exporting folder privileges
April 30, 2012 at 8:41 am
I know this is an old post and the person who asked this may not even bother about the solution anymore. But since the post is not marked as answered yet, I thought it will be helpful if I chip in my bit here for those who may come here looking for an answer:people
The problem here is the space between Queryout and the path to the file - One can try the below and it would work just fine!
bcp "Select LoanNo,PrepayVector1,DefaultVector1,RecoveryLag,LossSeverity from CurveTempDB.dbo.tLoanVectors where cusip='86359B6G1' " queryoutC:\Sample.txt -T -c
Hope this helps,
Ananthram
August 2, 2012 at 11:13 am
But you have not mentioned server name. when I try withour server name, it is giving error occured while establishing server connection.
and also is there any possibility that with out server name and database name, can we run the bcp using batch scrips please
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply